我正在学习 R 并且只是尝试读取 stata 数据文件,但收到以下错误:
X <- Stata.file(Stata_File)
nchar(varlabs) 中的错误:无效的多字节字符串 253
此处的多个 Mac 用户在使用该程序时遇到此错误,但它在 PC 上运行良好。谷歌搜索这个错误似乎说它与 R 包有关,但我找不到解决方案。有任何想法吗?谢谢你的帮助!!
到错误点的R代码如下:
Root <- "/Users/Desktop/R_Training"
PathIn <- paste(Root,"Data/Example_0",sep="/")
# The 2007 Dominican Republic household member file (96 MB)
Stata_File <- "drpr51fl.dta"
# Load the memisc package:
library(memisc)
# Set the working directory:
setwd(PathIn)
# (1) Determine which variables we want:
# The Stata.file function (from memisc) reads the "header"
# of our Stata file so you can see what it contains
# and choose the variables you want.
X <- Stata.file(Stata_File)
**Error in nchar(varlabs) : invalid multibyte string 253**
以下是我的会话信息:
R 版本 2.13.1 (2011-07-08) 平台:x86_64-apple-darwin9.8.0/x86_64 (64-bit)
语言环境:[1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8
附加的基础包:[1] grid stats graphics grDevices utils datasets [7] methods base
其他附加包:[1] memisc_0.95-33 MASS_7.3-13 lattice_0.19-30