Re: [R] Accessing variables in a data frame

2011-06-27 Thread Serguei Kaniovski
Thanks! I did not realize you can access variables by name like this. Serguei __ 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 comm

Re: [R] Accessing variables in a data frame

2011-06-26 Thread Bill.Venables
t[, x[1:3]] The results, in both cases, should be data frames Bill Venables. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Serguei Kaniovski Sent: Sunday, 26 June 2011 10:01 PM To: r-help@r-project.org Subject: [R] Accessing var

[R] Accessing variables in a data frame

2011-06-26 Thread Serguei Kaniovski
Hello My data.frame (dat) contains many variables named var.names and others named var.names_var.id For example var.name <- c("gdp","inf","unp") var.id <- c("w","i") x <- paste(var.name, rep(var.id, each=length(var.name)), sep="_") How can I access variables in the dama.frame by names listed