Possible Duplicate:
Drop Columns R Data frame
Suppose, I have the following dataframe, and want to delete column "dataB" what would be R command for that?
y <- data.frame(k1=c(101,102,103,104,105,106,107,108),
B=c(11,12,13,NA,NA,16,17,18),
dataB=11:18)
To drop duplicate columns from pandas DataFrame use df. T. drop_duplicates(). T , this removes all columns that have the same data regardless of column names.
Remove Duplicate rows in R using Dplyr – distinct () function. Distinct function in R is used to remove duplicate rows in R using Dplyr package. Dplyr package in R is provided with distinct() function which eliminate duplicates rows with single variable or with multiple variable.
The most easiest way to drop columns is by using subset() function. In the code below, we are telling R to drop variables x and z. The '-' sign indicates dropping variables. Make sure the variable names would NOT be specified in quotes when using subset() function.
This: y$B <- NULL
removes column B
from dataframe y
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With