Dear All,
I have searched the forum but could not find a thread about the way to solve my
problem. I am trying to find a way to use a subset of a list of variable names I have
when I call the "cbind" command to create a data matrix, after I have attached a
dataset. The nature of my program necessitates that I create different data matrices
using a subset of variable names multiple times. So, when I change the variables for
the analysis, I need to make 5-6 manipulations to my program and it is painful. Is
there a way to use a character vector containing variable names in the cbind command?
What I tried is
1.I loaded and attached a data set.
2.I have a character vector containing the variables I want to use in the analysis. Say
name <- c("a1","a2","a3", "a4")
I have several vectors of this type to use in the analysis, so to create a data
matrix, I use the cbind command but as expected the following does not work:
X <- cbind(1, name)
cbind requires "," between the variable names so when I do
X <- cbind(1, paste(",", name, collapse=""))
it still doesn't work although the printed version of the second portion is more or
less what I need.
Is there a way to do this?
Thanks for the help in advance.
Alex
---------------------------------
[[alternative HTML version deleted]]
______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html