[R] automatic coercion to character

Peter Alspach Peter.Alspach at plantandfood.co.nz
Wed Feb 2 04:35:13 CET 2011


Tena koe Lorenz

c() combines the elements to form a vector and all elements of a vector must be of the same type.  If you elements of different types you need to use a list.  Note, a data.frame is a special type of list.

HTH ....

Peter Alspach

> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Lorenzo Cattarino
> Sent: Wednesday, 2 February 2011 3:40 p.m.
> To: r-help at r-project.org
> Subject: [R] automatic coercion to character
> 
> Hi R users
> 
> 
> 
> I am wondering how I can avoid automatic coercion of my numeric vector
> elements to character
> 
> 
> 
> init <- c(age='N', R=as.numeric(0.5), S=as.numeric(0.8))
> 
> 
> 
> I have used as.numeric() but it does not seem to work
> 
> 
> 
> Thank you
> 
> Lorenzo
> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org 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.

The contents of this e-mail are confidential and may be subject to legal privilege.
 If you are not the intended recipient you must not use, disseminate, distribute or
 reproduce all or any part of this e-mail or attachments.  If you have received this
 e-mail in error, please notify the sender and delete all material pertaining to this
 e-mail.  Any opinion or views expressed in this e-mail are those of the individual
 sender and may not represent those of The New Zealand Institute for Plant and
 Food Research Limited.



More information about the R-help mailing list