Is there a way in R to have a variable evaluated as a column name when creating a data frame (or in similar situations like using cbind)?
For example
just use colnames after creation. eg
a <- "mycolA" b<- "mycolB" d <- data.frame(a=1:10, b=rnorm(1:10)) colnames(d)<-c(a,b) d mycolA mycolB 1 -1.5873866 2 -0.4195322 3 -0.9511075 4 0.2259858 5 -0.6619433 6 3.4669774 7 0.4087541 8 -0.3891437 9 -1.6163175 10 0.7642909