Dear List,
I like to assign names to vectors in a loop.
Here is a short example:
DMUs <-
as.data.frame(matrix(c("b","c","d","a","e","h","i","f","g","j","k","l"),ncol
=7, nrow=10))
colnames(DMUs) <- v_DMUs <- c("a","b","c","d","e","f","g")
for (i in v_DMUs)
assign(paste("eff_val",i,sep="."),abs(rnorm(10)))
Now I like to find a solution for applying following operation in a loop for
all vectors eff_val.i (with i = a:g) and names in columns (columns i = a:g)
of dataframe DMUs. Perhaps there is a solution without loop, too?!
names(eff_val.a) <- t(subset(DMUs, select="a"))
I tried the following. But this results in an error-message!
for (i in v_DMUs)
names(paste("eff_val.",i,sep="")) <- t(subset(DMUs,select =
paste("",i,sep="")))
I don't know how to beat this bastard ;-)
Thanks for your support.
Henning
[[alternative HTML version deleted]]
______________________________________________
[email protected] 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.