Reputation: 31
I can obtain the names of my variables of a data frame with the command "names (df)
". It gives say:
#[1] "V1" "V2" "V3"
But I would like to obtain a vector, something like this:
c("V1", "V2", "V3")
Is this possible in R?
Thanks in advance for your response
Richard
Upvotes: 1
Views: 1043
Reputation: 1328
It is possible and you can just make a new vector with the names like this:
x <- names(df)
..and the names will be stored in vector x
Upvotes: 1