[R] Convert character Variables to numeric
jim holtman
jholtman at gmail.com
Wed Aug 26 22:33:28 CEST 2015
Please provide a sample of the data that you are trying to convert. BTW
does it have commas in numeric values, or what else is strange about the
data. The error message is very clear in the column of data that you are
trying to convert is not numeric.
Jim Holtman
Data Munger Guru
What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.
On Wed, Aug 26, 2015 at 4:30 AM, Arun84441 <arun.kumar8 at safexpress.com>
wrote:
> I have imported the csv file having 398800 obs of 30 variables. There is a
> variable "TOTALFRT" which is showing as character in R environment. I am
> trying to convert it to numeric by using as.numeric function.
> Wherein function is converting character to numeric but with an error
> message "Warning message:
> NAs introduced by coercion", it omitted 388800 entries. Hence I am unable
> to
> perform calculation.
>
> Is there anyway by which I can convert NAs to numeric??
>
> Below is the code I used for conversion :-
>
> Mac<-read.csv("July'15.csv", header = TRUE)
> Book=as.character(Mac$TOTALFRT)
> V = as.numeric(Book)
>
>
>
>
>
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Convert-character-Variables-to-numeric-tp4711518.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>
[[alternative HTML version deleted]]
More information about the R-help
mailing list