简体   繁体   中英

r read.table misread special symbols

I am supposed to use read.table (not other functions) to import my data.
The data looks like the following:

    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
   ...

The read.table cannot properly read "Cote d'Ivoire" because it has the prime symbol. How do I fix that by changing the parameters of the read.table function?

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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