[R] assign vector name

Bill.Venables at csiro.au Bill.Venables at csiro.au
Sat Dec 1 07:43:53 CET 2007


Well, you can do it:

assign(paste("myname", name[1], sep = "."), seq(1:10))

but this looks clumsy to me, as if you were trying to make R do
something the same way that you do things in some other system.  This is
nearly always a bad idea. My advice is to learn how to do things the R
way.


Bill Venables
CSIRO Laboratories
PO Box 120, Cleveland, 4163
AUSTRALIA
Office Phone (email preferred): +61 7 3826 7251
Fax (if absolutely necessary):  +61 7 3826 7304
Mobile:                         +61 4 8819 4402
Home Phone:                     +61 7 3286 7700
mailto:Bill.Venables at csiro.au
http://www.cmis.csiro.au/bill.venables/ 

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On Behalf Of livia
Sent: Saturday, 1 December 2007 2:12 AM
To: r-help at r-project.org
Subject: [R] assign vector name


Hello,

I have got a vector, for example seq(1:10), and I have an array "name"
defined before which contain the vector name I would like to use. So
name[1]= "price". I would like to name the vector in the following
codes:

paste("myname", name[1]) <- seq(1:10)

But it does not work. Could anyone give me some advice? Many thanks.
-- 
View this message in context:
http://www.nabble.com/assign-vector-name-tf4918696.html#a14077275
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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.



More information about the R-help mailing list