我正在尝试将NYPD stop-and-frisk数据导入R.数据位于SPSS .por文件中,网址为http://www.nyc.gov/html/nypd/downloads/zip/analysis_and_planning/YYYY.zip 其中YYYY是2003年至2012年的一年
大多数文件加载正常,但2004,2007和2008文件都给我这个错误:
> library(foreign)
> mydata= read.spss("2004.por", to.data.frame=TRUE)
Error in read.spss("2004.por", to.data.frame = TRUE) :
error reading portable-file dictionary
In addition: Warning message:
In read.spss("2004.por", to.data.frame = TRUE) : Bad character in time
Execution halted
Run Code Online (Sandbox Code Playgroud)
关于如何调试这个的任何建议?我意识到read.spss不支持最新的SPSS版本,但鉴于大多数文件(10个中的7个)正确导入,我想知道它是否更微妙.
psppire无需投诉地加载所有文件,但数据看起来已损坏,其中一些字段似乎与其他字段结合,而某些字段中的二进制数据.
我按照Read SPSS file into Rmemisc中的建议取得了一些成功。即,安装后:memisc
> install.packages('memisc')
Run Code Online (Sandbox Code Playgroud)
您可以相当轻松地读取数据:
> library(memisc)
> data <- as.data.set(spss.portable.file('2004.por'))
Run Code Online (Sandbox Code Playgroud)
虽然我还没有彻底检查数据,但乍一看似乎是正确的。
| 归档时间: |
|
| 查看次数: |
1323 次 |
| 最近记录: |