[R] subsetting a dataframe
jfox at mcmaster.ca
Mon Apr 7 20:48:20 CEST 2003
The following should work for you:
olddf[[colname]] <- NULL
I hope this helps,
At 11:28 AM 4/7/2003 -0700, Chris Handorf wrote:
>How does one remove a column from a data frame when the name of
>the column to remove is stored in a variable?
>colname <- "LOT"
>newdf <- subset(olddf,select = - colname)
>The above statement will give an error, but thats what I'm trying to
>If I had used:
>newdf <- subset(olddf,select = - LOT)
>then it would have worked, but as I said the column name is stored in a
>so I can't just enter it explicity.
Department of Sociology
email: jfox at mcmaster.ca
More information about the R-help