Currently I have a CSV with mixed input types that I am trying to read in and 
reformat without having to list off all the column names.  Below is an example 
of the data:

HouseColor, HouseSize, HouseCost
Blue, 1600, 160e3
Blue, 1600, 160e3

Actually I have about 60 columns like this, so imagine the above repeated about 
30 times column-wise.  

Luckily the ones in scientific notation are grouped together, i.e. columns 
11-56. 

Using read.csv or as.numeric, is there a way to convert all those in scientific 
format over to general numeric syntax?  

Right now I have something like the following
input_df<-read.csv(InputFile, skip=0, header=TRUE, strip.white = TRUE)

I tried:
as.numeric(input_df[, 11:56])
but this returns an error 
Error: (list) object cannot be coerced to type 'double'

Oddly it does appear to work successfully row-wiseas.numeric(input_df[1, 
11:56]) 
as.numeric(input_df[2, 11:56])
etc.

However, trying it on multiple rows produces the same error as above:
as.numeric(input_df[1:2, 11:56])

After a bit, I became a bit frustrated that this was not working so I tried 
just deleting the columns:
input_df[1, 11:56]<-NULL

This also failed, so are there any suggestions about how to convert the values 
in scientific notation over to standard numeric syntaix?

Thank you again again for all your insights and feedback. 




______________________________________________
R-help@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.

Reply via email to