download.file中的错误;没有这样的文件或目录

问题描述:

我是一个R和编程福利局,并试图从下载文件:download.file中的错误;没有这样的文件或目录

https://d396qusza40orc.cloudfront.net/getdata%2Fdata%2Fss06hid.csv

我用download.file和我的代码是:

网址< - 'https://d396qusza40orc.cloudfront.net/getdata%2Fdata%2Fss06hid.csv '

DOC < -download.file(URL,destfile ='/测试/ communities.csv')

我得到一个错误:

错误download.file(URL,destfile = “./test/communities.csv”): 无法打开destfile './test/communities.csv',原因 '没有这样的文件或目录'

但是当我检查使用getwd()我的工作目录就说明它的存在:

getwd() [1] "C:/Users/puneet.kumar/Desktop/R practice/R lesson/Data cleaning/test"

能否请你帮我这个。预先感谢您的帮助。

+1

测试文件夹中可能没有测试文件夹。因此,使用'destfile ='communities.csv''或'destfile ='../test/communities.csv''。 – lukeA

download.file(url = "https://d396qusza40orc.cloudfront.net/getdata%2Fdata%2Fss06hid.csv", destfile = "communities.csv")

这应该做你所需要的。由于您已经在test中,因此您没有指定./test,因为这是在寻找.../test/test