Using R to download zipped data file, extract, and import data

前端 未结 8 1471
Happy的楠姐
Happy的楠姐 2020-11-22 14:12

@EZGraphs on Twitter writes: \"Lots of online csvs are zipped. Is there a way to download, unzip the archive, and load the data to a data.frame using R? #Rstats\"

I

8条回答
  •  孤独总比滥情好
    2020-11-22 14:44

    Just for the record, I tried translating Dirk's answer into code :-P

    temp <- tempfile()
    download.file("http://www.newcl.org/data/zipfiles/a1.zip",temp)
    con <- unz(temp, "a1.dat")
    data <- matrix(scan(con),ncol=4,byrow=TRUE)
    unlink(temp)
    

提交回复
热议问题