[R] c() question

Simon Fear Simon.Fear at synequanon.com
Mon Mar 29 12:26:15 CEST 2004


Christoph, yes there IS a way, such as the horrible

eval(parse(text=paste("c(", my.group[1],
  " = ", class.weight[2], ",", my.group[2], " = ", class.weight[1], ")", sep="")))

BUT I would suggest you rethink whether there isn't a an altogether
more straightforward way to do what you want. For example, 

tmp <- class.weight
names(tmp) <- my.group

HTH

> -----Original Message-----
> From: Christoph Lehmann [mailto:christoph.lehmann at gmx.ch]
> Sent: 29 March 2004 09:58
> To: r-help at stat.math.ethz.ch
> Subject: [R] c() question
> 
> 
> Security Warning: 
> If you are not sure an attachment is safe to open contact 
> Andy on x234. 
> There are 0 attachments with this message. 
> ________________________________________________________________ 
>  
> Hi
> 
> I need to define the following
> 
> 	c("one group" = class.weight[2], "other group" = 
> class.weight[1])
> #class.weight = c(1,2)
> 
> but I don't like the hard-coded way and would like to use
> 
> 	my.group <- array(c("one group", "other group"))
> 
> but now
> 
> 	c(my.group[1] = class.weight[2], my.group[2] = class.weight[1])
> 
> gives an error
> 
> how can I solve this small problem?
> 
> thanks for a hint
> 
> christoph
> 
> -- 
> Christoph Lehmann <christoph.lehmann at gmx.ch>
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
>  
 
Simon Fear 
Senior Statistician 
Syne qua non Ltd 
Tel: +44 (0) 1379 644449 
Fax: +44 (0) 1379 644445 
email: Simon.Fear at synequanon.com 
web: http://www.synequanon.com 
  
Number of attachments included with this message: 0 
 
  
This message (and any associated files) is confidential and\...{{dropped}}




More information about the R-help mailing list