[R] as.numeric : what goes wrong?

2007-08-24 Thread Wolfgang Polasek
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]]

Re: [R] as.numeric : what goes wrong?

2007-08-24 Thread Uwe Ligges
Wolfgang Polasek 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 Probably this is a factor? as.numeric(j1[1]) [1] 1990 And this is the number the factor level 896 has been coded with.

Re: [R] as.numeric : what goes wrong?

2007-08-24 Thread jim holtman
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 [EMAIL PROTECTED] 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