Skip to content

can i use a variable to describe the dimension name of a data.frame?

2 messages · Jie TANG, David Winsemius

#
On Aug 18, 2011, at 1:36 AM, Jie TANG wrote:

            
If you are asking how to access the n-th column then try this:

data[[n]]  # returns a vector

  or

data[1:5]  # returns a dataframe

You could also use:

vname <- paste("V", 1:5, sep="")
data[vname]

This does suggest that yoy need to read your introductory material  
more closely, because this would be covered in an early chapter.