R claims that data is non-numeric, but after writing to file is numeric -


i have read in table in r, , trying take log of data. gives me error last column contains non-numeric values:

> log(td_complete) error in math.data.frame(list(x2011.01 = c(187072l, 140815l, 785077l,  :  non-numeric variable in data frame: x2013.05 

the data "looks" numeric, i.e. when read brain interprets numbers. can't totally wrong since following work:

> write.table(td_complete,"c:\\tmp\\rubbish.csv", sep = ",") > newdata = read.csv("c:\\tmp\\rubbish.csv") > log(newdata) 

the last line happily output numbers.

this doesn't make sense me - either data numeric when read in first time round, or not. ideas might going on?

edit: unfortunately can't share data, it's confidential.

review colclasses argument of read.csv(), can specify type each column should read , stored as. might not helpful if have large number of columns, using makes sure r doesn't have guess type of data you're using.

just because "the last line happily output numbers" doesn't mean r treating values numeric.

also, see of data.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -