问题
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:
- description is a specific zip file destination, which outputs in var tf as c://...//345du.zip
- filename is summarySCC_PM25.rds, which is the file to be extracted from tf
- open is already established in the var so black should be fine
- 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