R Error: unknown input format

穿精又带淫゛_ 提交于 2019-12-24 13:33:34

问题


NEI <- readRDS(unz(tf, filename = "summarySCC_PM25.rds", open = "", encoding = getOption("encoding")))

Variable tf is a temporary file with a very specific location saved on the hard drive. It is my understanding that the format for unz() is:

unz(description, filename, open = "", encoding = getOption("encoding"))

As I read the documentation, I am interpreting that my application of the code is accurate as that:

  1. description is a specific zip file destination, which outputs in var tf as c://...//345du.zip
  2. filename is summarySCC_PM25.rds, which is the file to be extracted from tf
  3. open is already established in the var so black should be fine
  4. encoding labels the language type.

Within the context of the code above, I receive "Error: unknown input format" from R 3.1.1. I need clarification on what might be happening as that I interpret my code to be the same as:

NEI <- readRDS("summarySCC_PM25.rds")

Am I misinterpreting this?


回答1:


I found your data online so that I can read your file. It was available from here:

https://www.linkedin.com/today/post/article/20140617173447-5576436-explore-n-analyze-data-assignment-2

> unzip("C:\\Users\\jmiller\\Downloads\\exdata_data_NEI_data.zip")
> NEI <- readRDS("summarySCC_PM25.rds")
> dim(NEI)
[1] 6497651       6
> colnames(NEI)
[1] "fips"      "SCC"       "Pollutant" "Emissions" "type"      "year"    



回答2:


Avoid unz() and use unzip(withanindex) since the temp file is a moving target



来源:https://stackoverflow.com/questions/25772964/r-error-unknown-input-format

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!