[R] as.numeric : what goes wrong?
jim holtman
jholtman at gmail.com
Fri Aug 24 14:00:59 CEST 2007
Do an 'str' on the vector. Are you sure it is not a 'factor'?
Try:
as.numeric(as.character(j1[1]))
On 8/24/07, Wolfgang Polasek <wolfgang.polasek at gmail.com> wrote:
> I have a character vector j1 created from dimnames and want it to convert it
> to numeric.
> Like the first element:
>
> > j1[1]
> f896
> 1 896
>
> > as.numeric(j1[1])
> [1] 1990
>
> why is it not 896 as it should be?
> This is true fr the whole vector.
>
> Thanks
> W.P.
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem you are trying to solve?
More information about the R-help
mailing list