[R] Warning message: In scan(file, what, nmax...)
jim holtman
jholtman at gmail.com
Mon Dec 3 14:16:02 CET 2012
According to the dump of the lines you included, I would assume that a
semicolon (";") is the field separator and that the comma is part of
the 3rd field and looks like the decimal point. Can you show what you
expect the output to be in terms of what goes into what columns. Here
is what I get when I read your data:
> x <- read.table(text = 'Country10;Year10;GDP
+ Andorra;2010;41,138
+ Andorra;2009;44,591
+ Andorra;2008;49,981
+ Andorra;2007;48,431
+ Andorra;2006;43,541
+ Andorra;2005;40,821
+ Andorra;2004;38,381
+ Andorra;2003;32,55
+ Andorra;2002;25,532', sep = ';', header = TRUE, dec = ',')
>
> x
Country10 Year10 GDP
1 Andorra 2010 41.138
2 Andorra 2009 44.591
3 Andorra 2008 49.981
4 Andorra 2007 48.431
5 Andorra 2006 43.541
6 Andorra 2005 40.821
7 Andorra 2004 38.381
8 Andorra 2003 32.550
9 Andorra 2002 25.532
>
On Mon, Dec 3, 2012 at 5:30 AM, F86 <faradj.g at gmail.com> wrote:
> Dear David,
>
> Than you for helping me.
>
> I tried with ","
>
> Data1<-read.table("/Users/kama/Analysis/GDP10.csv",header=TRUE,sep=",")
> Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,
> :
> line 116 did not have 2 elements
>
> i also tried:
>
> Data1<-readLines("/Users/kama/Analysis/GDP10.csv",n=10)
>> Data1
> [1] "Country10;Year10;GDP" "Andorra;2010;41,138" "Andorra;2009;44,591"
> [4] "Andorra;2008;49,981" "Andorra;2007;48,431" "Andorra;2006;43,541"
> [7] "Andorra;2005;40,821" "Andorra;2004;38,381" "Andorra;2003;32,55"
> [10] "Andorra;2002;25,532"
>
>
>
>
>
>
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Warning-message-In-scan-file-what-nmax-tp4651689p4651809.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
--
Jim Holtman
Data Munger Guru
What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.
More information about the R-help
mailing list