Re: [R] covert entire dataset to numeric while persuing percentage values

2015-02-26 Thread JS Huang
The following data.frame x as one column named Percent. x Percent 1 10% 2 20% 3 30% as.numeric(substr(x$Percent,1,nchar(x$Percent)-1)) [1] 10 20 30 -- View this message in context:

Re: [R] covert entire dataset to numeric while persuing percentage values

2015-02-26 Thread Jeff Newmiller
I think you are getting ahead of yourself. You use the term dataset, which is colloquial and not precise. The read.csv function returns a data.frame, in which each column can have its own storage mode (type). Most data.frames do not have all columns of the same type... if they were you might

Re: [R] covert entire dataset to numeric while persuing percentage values

2015-02-26 Thread jim holtman
It would help a lot if you posted a subset of your data using 'dput' so that we know what it actually looks like. You have character data mixed with numerics, so you will be NAs in some cases. Conversion of percent to numeric is accomplished with something like this: x - c('12%', '6%',

[R] covert entire dataset to numeric while persuing percentage values

2015-02-26 Thread Methekar, Pushpa (GE Transportation, Non-GE)
Hi , I am little confused about how to covert entire dataset to numeric . As I read data like.. Xelements =read.csv(file. Choose(),header = T, stringsAsFactors=FALSE) str(xelements ) str(xelements) 'data.frame': 731 obs. of 4 variables: $ Engine.Speed : chr rpm ES rpm 1049 ... $