[R] "unexpected numeric constant" while reading tab delimited csv file
Mike Marchywka
marchywka at hotmail.com
Mon Nov 22 12:29:34 CET 2010
----------------------------------------
> Date: Mon, 22 Nov 2010 01:57:54 -0800
> From: jdnewmil at dcn.davis.ca.us
> To: madrazel at interia.pl
> CC: r-help at r-project.org
> Subject: Re: [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
> 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?
The OP explained that and if you believe OP changing intended file changes
the error message. And, yes, I would strongly suggest getting cygwin
so you have some tools other than posting incomplete information of calling
tech support LOL. In this case, you would use something like "od" to verify
that your file is as you expect. Just as printing numerical data often
truncated digits, unprintable chars don't always show up on printing.
od -ax or something may be informative. Changing the tab may have caused
editor to change line endings or something else. Smart editors often
mess stuff up.
>
> Perhaps you should follow the posting guide instructions...
>
> ______________________________________________
> 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.
More information about the R-help
mailing list