madr
2010-Nov-22 08:29 UTC
[R] "unexpected numeric constant" while reading tab delimited csv file
my csv file is very simple - just one line for purpose of this test: 0{TAB}0 and read function is this: csvdata = read.csv(file="d:/s/test.csv",head=FALSE,sep="\t") then error comes: Error in source("d:/test.csv") : d:/test.csv:1:9: unexpected numeric constant 1: 0 0 but when I change delimiter to ; (colon) then error not shows up anymore -- View this message in context: http://r.789695.n4.nabble.com/unexpected-numeric-constant-while-reading-tab-delimited-csv-file-tp3053252p3053252.html Sent from the R help mailing list archive at Nabble.com.
madr
2010-Nov-22 09:06 UTC
[R] "unexpected numeric constant" while reading tab delimited csv file
the problem shows up only in console when script is loaded thru source() and separator character is eighter tab or space, strangely, when I'm running script directly form file in text environment everything is ok. [I'm reposing this because my previous post didn't get on the list because double quote character at the beginning of a subject was eaten up when Re: was added, now everything should be ok ]] -- View this message in context: http://r.789695.n4.nabble.com/unexpected-numeric-constant-while-reading-tab-delimited-csv-file-tp3053252p3053291.html Sent from the R help mailing list archive at Nabble.com.
Jeff Newmiller
2010-Nov-22 09:57 UTC
[R] "unexpected numeric constant" while reading tab delimited csv file
madr wrote:> my csv file is very simple - just one line for purpose of this test: > 0{TAB}0 > > and read function is this: > csvdata = read.csv(file="d:/s/test.csv",head=FALSE,sep="\t") > > then error comes: > > Error in source("d:/test.csv") : > d:/test.csv:1:9: unexpected numeric constant > 1: 0 0 > > > but when I change delimiter to ; (colon) then error not shows up anymore >You seem to be referencing two different files somehow... one in the root directory of your drive D, and the other in a subdirectory D:/s. This may have something to do with it... or may be extraneous. You haven't indicated what your working environment is, though the OS seems likely to be some variant of Windows. In your other email, you mention a distinction between whatever this environment is (RGui?) and "console". Are you using Cygwin? could end-of-line termination (CRLF vs LF) be causing you difficulty? Perhaps you should follow the posting guide instructions...
Duncan Murdoch
2010-Nov-22 11:38 UTC
[R] "unexpected numeric constant" while reading tab delimited csv file
madr wrote:> my csv file is very simple - just one line for purpose of this test: > 0{TAB}0 > > and read function is this: > csvdata = read.csv(file="d:/s/test.csv",head=FALSE,sep="\t") > > then error comes: > > Error in source("d:/test.csv") : > d:/test.csv:1:9: unexpected numeric constant > 1: 0 0 > > > but when I change delimiter to ; (colon) then error not shows up anymoreYou used source, not read.csv. They aren't the same thing. If you typed what you said you typed, then you've hidden the real read.csv function behind your own, and your own calls source. But I don't think you typed what you said you typed. Duncan Murdoch