I have a simple csv file with around 20K+ values separated by commas. When I try to load the values in R, it gives me the error:
r:3: unexpected numeric constant
Here is the simple command of R that I executed
someThing <- c(0.080172405,0.06233087,0.04315185,0.0652015,0.03201301.......n)
n= 70,000 values
I cannot copy paste all the 20K+ values here. I googled this error and there is no special character or another thing except for some floating values.
http://pastebin.com/FVkUV6kY
The 5682-th entry is "0.0733 7422182"
, which has a space.
I think this is a simple problem of data processing.
There's a newline partway through the file, which is causing that section to look something like (replacing that newline with a space) and so after the space, there's an unexpected numeric constant.
... 0.0068243323,0.0733 7422182,0.07379706 ...
Here's how I found it:
b <- scan(file, what=character(0))
length(b)
The length is 2, not 1.
It can be read in as is like this:
b <- paste(b, collapse="")
b <- substring(b, 3, nchar(b)-1)
b <- strsplit(b,",")[[1]]
b2 <- as.numeric(b)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With