Thank you, but unfortunately it's not resolve my problem. After writing in R console e.g. a2 a should get the values. Do you know how to read file 2 into R?
2010/11/19 Joshua Wiley <jwiley.ps...@gmail.com>: > Hi Robert, > > What about a named list? This will generalize to your two text files > one with data, the other with names. > > x <- c("a2","b7","c8") > y1 <- c(1,2,3,2) > y2 <- c(4,2,7,5,4,3,8) > y3 <- c(1:10) > > > dat <- list(c(1,2,3,2), c(4,2,7,5,4,3,8), c(1:10)) > names(dat) <- c("a2","b7","c8") > dat > # example > dat$a2 > dat[["a2"]] > > > ## or using your variables > dat2 <- list(y1, y2, y3) > names(dat2) <- x > > Cheers, > > Josh > > > On Fri, Nov 19, 2010 at 2:57 AM, Robert Ruser <robert.ru...@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 >> >> 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 >> >> ______________________________________________ >> 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. >> > > > > -- > Joshua Wiley > Ph.D. Student, Health Psychology > University of California, Los Angeles > http://www.joshuawiley.com/ > ______________________________________________ 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.