I am having a dataframe in r. I want to delete those rows where the values of a string in two columns are equal. I used match function in r but was not able to get desired output. For example my dataframe is
ALDH1A1 ALDH1A1
ITGA7 CHRNA1
PPP1R9A ACTG1
SRGN SRGN
GRB7 ERBB2
PAK1 ERBB2
DLG4 DLG4
PIK3R2 ERBB2
PTPN18 ERBB2
ERBB2 ERBB2
SMURF2 ARHGAP5
NF2 ERBB2
CD82 CD82
ERRFI1 ERBB2
CD44 CD44
TOB1 TOB1
and my desired data frame after filtering out the rows with equal column values is
ITGA7 CHRNA1
PPP1R9A ACTG1
GRB7 ERBB2
PAK1 ERBB2
PIK3R2 ERBB2
PTPN18 ERBB2
SMURF2 ARHGAP5
NF2 ERBB2
ERRFI1 ERBB2
Assuming that you have your data into an R object called df with columns V1 and V2, you can achieve this very simply with dplyr doing
Or,
where V1 and V2 are the names of the columns, unquoted.
Let us imagine your dataset is called
dta
then simply
Please provide the
dput
in order to reproduce your example.