将zip文件加载到R中

时间:2019-03-05 03:21:59

标签: r zip

我遇到以下错误:Error in file (file, "rt"): cannot open the connection

download.file("http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/F-F_Research_Data_5_Factors_2x3_CSV.zip", destfile="F-F_Research_Data_5_Factors_2x3_CSV.zip")

unzip("F-F_Research_Data_5_Factors_2x3_CSV.zip")

unzip("F-F_Research_Data_5_Factors_2x3_WIRELESS_CSV.zip")

data <- read.delim("F-F_Research_Data_5_Factors_2x3_Wireless_CSV.TXT", sep = "|")

1 个答案:

答案 0 :(得分:0)

我能够通过以下方式读取数据集:

download(url="http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/F-F_Research_Data_5_Factors_2x3_daily_CSV.zip", dest="<directory and filename>/F-F_Research_Data_5_Factors_2x3_daily_CSV.zip", mode="wb") 
unzip ("<directory and filename>/F-F_Research_Data_5_Factors_2x3_daily_CSV.zip", exdir = "Yourfilename")

x <- read_csv("<directory and filename>/F-F_Research_Data_5_Factors_2x3_daily.CSV", skip = 3)

x %>%
  mutate_at(vars(-X1), funs(./100))