Upload the file to my working directory

I want to upload the file directly to the working directory I can do this in the temp directory: download.file("http://www.abc.com/abc.zip",temp) but what do I need to replace temp to load it into the working directory?

+5
source share
2 answers

The second argument download.file()is destfile, and it must be specified. I don’t have a Windows machine to test this, but both of these functions work in my Linux window, and I don’t understand why at least the second one will not work on Windows either:

download.file("http://www.abc.com/abc.zip", "./abc.zip")
download.file("http://www.abc.com/abc.zip", "abc.zip")

The second of them indicates that if you simply specify the file name, the file will be loaded into the current working directory and saved under the specified name.

+5
source

URL- , basename, "filename":

u <- "http://www.abc.com/abc.zip"
basename(u) # "abc.zip"

# downloads to current directory:
download.file(u, basename(u))

# downloads to subdirectory "foo":
download.file(u, file.path("foo", basename(u)))
+7

All Articles