Hi:



On Fri, Nov 19, 2010 at 2:57 AM, Robert Ruser <robert.ruser@gmail.com>wrote:

> Hello R Users,
> I have vectors
> x <- c("a2","b7","c8")
> y1 <- c(1,2,3,2)
> y2 <- c(4,2,7,5,4,3,8)
> y3 <- c(1:10)
> and I want to assign values form vector y1 to a new variable which
> name comes from the 1st value of the vector x etc. How to do it using
> only vector x.  As a result I should have:
> a2 <- y1
> b7 <- y2
> c8 <- y3
>

l <- list(y1, y2, y3)
for(i in seq_along(x)) assign(x[i],  l[[i]])

>
> More general problem: I have 2 txt files.
> First is a one column
> C4
> C6
> F
> D
> D1
> D2
> D5
> D6
> ....
> Second is (non-define number of columns):
> 44, 60, 65, 139, 138
> 47
> 48
> 49, 46
> .....
> is it possible to automatically assign:
> C4 <- c(44, 60, 65, 139, 138)
> C6 <- c(47)
> ...
>
> Same concept as above.

HTH,
Dennis


> I would appreciate for any help.
>
> Robert
>
> ______________________________________________
> R-help@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.
>

	[[alternative HTML version deleted]]

