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 in x, for
example to compute

gdp_w - gdp_i
inf_w - inf_i
unp_w - unp_i

or

gdp - gdp_w
inf - inf_w
unp - unp_w

without needing to code each difference separately?

Thanks for your help!
Serguei Kaniovski
        [[alternative HTML version deleted]]

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

Reply via email to