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
Just to start things off: > var.name <- c("gdp","inf","unp") > var.id <- c("w","i") > > x <- paste(var.name, rep(var.id, each=length(var.name)), sep="_") > x [1] "gdp_w" "inf_w" "unp_w" "gdp_i" "inf_i" "unp_i" > Now the three differences: gdp_w - gdp_i inf_w - inf_i unp_w - unp_i Can be got u