我正在尝试使用 R 从从包含 JSON 文件的 API 下载的 LZMA 存档中提取文件。在我的计算机上,我可以在 Windows 资源管理器中手动提取文件,没有任何问题。
这是我目前的代码(已删除 API 详细信息):
tempFile <- tempfile()
destDir <- "extracted-files"
if (!dir.exists(destDir)) dir.create(destDir)
download.file("api_url.tar.xz", destfile = tempFile)
untar(tempFile, exdir = destDir)
当我尝试提取文件时,我收到以下错误消息:
/usr/bin/tar: This does not look like a tar archive
/usr/bin/tar: Skipping to next header
/usr/bin/tar: Exiting with failure status due to previous errors
Warning messages:
1: running command 'tar.exe -xf "C:\Users\XXX\AppData\Local\Temp\RtmpMncPWp\file2eec75e23a15" -C "extracted-files"' had status 2
2: In untar(tempFile, exdir = destDir) :
‘tar.exe -xf "C:\Users\XXX\AppData\Local\Temp\RtmpMncPWp\file2eec75e23a15" -C "extracted-files"’ returned error code 2
我正在使用带有 R 版本 3.3.1 (2016-06-21) 的 Windows 10。