从子文件夹读取R中的zip文件

贾西

我一直在为此扯头发。我正在尝试运行以下命令:

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)

但是,我认为它不起作用,因为我想要的实际文件(工资)位于名为“ core”的文件夹中-我通过将压缩文件下载到计算机来查看结构。如何在此代码中添加一些内容以在核心文件夹中查找并获取Salaries数据?如果可能,我想直接从URL进行操作。谢谢!

M--

您可以在存档文件中明确指定路径:

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)

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章