[R] as.numeric question

2006-04-27 Thread Paulo Brando
Dear all, 
 
Is there a way of keeping the actual information in a factor when
converting it to numeric? 
 
Example:
 
What I want:
 
as.numeric(factor(5:10))
5, 6, 7, 8, 9, 10
 
 
How R works:
 
as.numeric(factor(5:10)) #R example on 'as.numeric'
[1] 1 2 3 4 5 6
 
Thank you very much.
 
Paulo

Paulo M. Brando
Instituto de Pesquisa Ambiental da Amazonia (IPAM)
Santarem, PA, Brasil.
Av. Rui Barbosa, 136.
Fone: + 55 93 3522 55 38
www.ipam.org.br
E-mail: [EMAIL PROTECTED]
 
 

[[alternative HTML version deleted]]

__
R-help@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


Re: [R] as.numeric question

2006-04-27 Thread Duncan Murdoch
On 4/27/2006 5:24 PM, Paulo Brando wrote:
 Dear all, 
  
 Is there a way of keeping the actual information in a factor when
 converting it to numeric? 
  
 Example:
  
 What I want:
  
 as.numeric(factor(5:10))
 5, 6, 7, 8, 9, 10
  
  
 How R works:
  
as.numeric(factor(5:10)) #R example on 'as.numeric'
 [1] 1 2 3 4 5 6
  
 Thank you very much.

Convert to character first:

  as.numeric(as.character(factor(5:10)))
[1]  5  6  7  8  9 10

__
R-help@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