Error in nchar() when reading in stata file in R on Mac

和自甴很熟 提交于 2019-12-04 19:20:05

It seems like the encoding of strings in the file isn't what the program thinks it is... I guess the file was generated on a PC? Does it contain non-ACII column names or data strings?

Since you seem to have UTF-8 encoding, and (US/western europe) PC:s typically have latin-1, that could be the problem. I'd expect the same problem on Linux then (also UTF-8).

Possible work-arounds: Does the Stata.file method have an "encoding" option? Then you might try 'latin1' and hope for the best...

Another possibility is to start R with the --encoding=latin1 option.

This is what worked for me. You can force R to recognize every character by issuing the following command:

Sys.setlocale('LC_ALL','C')

Now run the previous command and all should be fine.

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