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

前端 未结 8 1472
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:37

    I found that the following worked for me. These steps come from BTD's YouTube video, Managing Zipfile's in R:

    zip.url <- "url_address.zip"
    
    dir <- getwd()
    
    zip.file <- "file_name.zip"
    
    zip.combine <- as.character(paste(dir, zip.file, sep = "/"))
    
    download.file(zip.url, destfile = zip.combine)
    
    unzip(zip.file)
    

提交回复
热议问题