나는이 데이터가있는 경우 :고유 한 행만 유지하면서 열을 무시하는 방법은 무엇입니까?
df1 <- data.frame(name = c("apple", "apple", "apple", "orange", "orange"),
ID = c(1, 2, 3, 4, 5),
is_fruit = c("yes", "yes", "yes", "yes", "yes"))
및 I 출력이 같다고 같은 ID
열에만 고유 행을 유지하지만 무시해야합니다 : 나는이 작업을 수행 할 수있는 방법
df2 <- data.frame(name = c("apple", "orange"),
ID = c(1, 4),
is_fruit = c("yes", "yes"))
df2
# name ID is_fruit
#1 apple 1 yes
#2 orange 4 yes
을 이상적으로는 dplyr
?
베이스 R :'df1 [! duplicated (df1 [-2]),]' –