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?
You will have to use quote =
when you read.table
to ignore the quoting character in Cote d'Ivoire.
df.1 <- read.table("your/file.txt", quote = "", header = TRUE, sep = "\t")