繁体   English   中英

r read.table误读特殊符号

[英]r read.table misread special symbols

我应该使用read.table(而不是其他函数)来导入我的数据。
数据如下所示:

    country year    pop continent   lifeExp gdpPercap
    Afghanistan 1952    8425333 Asia    28.801  779.4453145
    Afghanistan 1957    9240934 Asia    30.332  820.8530296
    Afghanistan 1962    10267083    Asia    31.997  853.10071
   ...
    Cote d'Ivoire   1987    10761098    Africa  54.655  2156.956069
    Cote d'Ivoire   1992    12772596    Africa  52.044  1648.073791
    Cote d'Ivoire   1997    14625967    Africa  47.991  1786.265407
    Cote d'Ivoire   2002    16252726    Africa  46.832  1648.800823
    Cote d'Ivoire   2007    18013409    Africa  48.328  1544.750112
   ...

read.table无法正确读取“科特迪瓦”,因为它带有撇号。 如何通过更改read.table函数的参数来解决此问题?

当您read.table时,必须使用quote =来忽略科特迪瓦的引号字符。

df.1 <- read.table("your/file.txt", quote = "", header = TRUE, sep = "\t")

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM