I am new to "R", still learning basics..
In one situation, I got some population data from a website, in xls format. When I tried to read that (using read.xls from gdata package), data came in R (a data frame). However, everything is character, which is fine so far.
After some cleansing of unnecessary rows and columns etc, I am trying to convert the numbers (present as characters) into numeric values wherein I am facing strange behaviour...
My data elements look like this (some sample here)
> class(males1)
[1] "factor"
> males1[1]
[1] 6,665,561
males1 is supposed to contain n rows, with one element each, the number of males per state. When I am applying as.numeric on the values, its actually giving me back a sum of digits
> as.numeric(males1[1])
[1] 35
When I convert that males1 into a vector, I get back a different error
> vv=as.vector(males1)
> vv[1]
[1] "6,665,561"
> as.numeric(vv[1])
[1] NA
Warning message:
NAs introduced by coercion
I am sure, I am missing on something really basic..
help please...