I have been ripping my hair out with this. I am trying to run the following:
temp <- tempfile()
download.file("http://seanlahman.com/files/database/baseballdatabank-2017.1.zip", temp, mode="wb")
table1 <- unz(temp, "Salaries.csv")
salaries <- read.csv(table1, sep=",", header=T)
However, I think it is not working because the actual file I want (Salaries) is in a folder called 'core' - I looked at the structure by downloading the zipped file to my computer. How can I add something to this code to look in the core folder and get the Salaries data? I want to do this directly from the URL if possible. Thanks!
You can explicitly specify the path within the archive file:
temp <- tempfile()
download.file("http://seanlahman.com/files/database/baseballdatabank-2017.1.zip", temp, mode="wb")
table1 <- unz(temp, "baseballdatabank-2017.1/core/Salaries.csv")
salaries <- read.csv(table1, sep=",", header=T)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With