Essentially I’d like to achieve this:
vars <- c(x1, x20, x37, etc)
summary(data[vars])
However, my list of variables is quite long and does not have commas between them.
Edit: Data has 500 variables and vars is the list I want to select. The variable names follow no pattern. The list is in the form x1 x20 x37 etc, i.e. separated by spaces. This list comes from a SAS syntax file and is not part of the R workspace.
I’ve looked into function that concatenate the variables with a separator such as cat(). Yet this needs an object from the beginning. Another way is to use find/replace in an editor (space to comma), but I consider this a dirty hack.
Clearly, I’m missing something when defining a variable list; there must be a simple solution.
Use this: