[R] assigment

Robert Ruser robert.ruser at gmail.com
Fri Nov 19 11:57:56 CET 2010


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

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

I would appreciate for any help.

Robert



More information about the R-help mailing list