Hi:
Perhaps you had something like this in mind:
df<-data.frame(a1=1:10, a2=11:20, a3=21:30, b1=101:110, b2=111:120,
b3=121:130)
avars <- names(df)[grep('^a', names(df))]
bvars <- names(df)[grep('^b', names(df))]
cvars <- paste('c', 1:length(avars), sep = '')
df <- within(df, for(i in seq_along(c
Hi Al,
Assuming that the order of the matrices resulting from selecting
"avars" and "bvars" is identical (it is at least in the example you
gave), then you can do:
dat <- data.frame(a1=1:10, a2=11:20, a3=21:30, b1=101:110, b2=111:120,
b3=121:130)
avars <- paste("a", 1:3, sep = '')
bvars <- paste
Hi all,
I frequently encounter datasets that require me to repeat the same calculation
across many variables. For example, given a dataset with total employment
variables and manufacturing employment variables for the years 1990-2010, I
might have to calculate manufacturing's share of total e
3 matches
Mail list logo