Is there a way to select all columns of a data frame except a column that has a particular name.
It would be the analog of df[, -1], except using the column name instead of the index?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can do this using vector subsetting. First, create a dummy data set:
Then use the
!operator to reverse the selection:Alternatively, you could have:
A slightly shorter version (courtesy of @Tomas):
To cope with multiple columns (courtesy of @Tyler)