How to remove rows which has identical string variable? Here is example data:
data <- data.frame(c("A", "C", "B"),
c("A", "B", "C"),
stringsAsFactors = FALSE)
head(data)
# c..A....C....B.. c..A....B....C..
#1 A A
#2 C B
#3 B C
For the output I would like to get this dataframe:
# c..A....C....B.. c..A....B....C..
#2 C B
#3 B C
As you can see in the first row, same A and A are deleted. tidyverse approach preferred.
CodePudding user response:
data <- data.frame(x = c("A", "C", "B"),
y = c("A", "B", "C"),
stringsAsFactors = FALSE)
library(dplyr)
data %>%
filter(x != y)
x y
1 C B
2 B C