To remove a column from a data frame in R, you can use the dplyr
package from the tidyverse
. Here's an example of how to remove a column named column_name
from a data frame called df
:
main.r53 chars5 lines
This code uses the select()
function to remove the specified column from the data frame. The -
sign indicates that we want to remove the column. Note that this code does not modify the original data frame, but rather creates a new data frame with the specified column removed. If you want to modify the original data frame, you can assign the result back to the original object (as shown above).
gistlibby LogSnag