2015-09-24 71 views
0

我应该使用read.table(不是其他函数)来导入我的数据。
数据如下所示:r 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函数的参数来解决这个问题?

+0

是'报价= “”' – Ananta

+0

你能后整个数据集文件 – rbm

+0

你用'九月= “\ t” 的'? – Veera

回答

2

当您read.table忽略科特迪瓦的引用字符时,您将不得不使用quote =

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