Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想根据具有重复 ID 的列之一对 3 列进行子集化,这样我只能得到 3 列具有唯一值
structure(list(ID = 1:4, x = c(46L, 47L, 47L, 47L), y = c(5L,
6L, 7L, 7L)), .Names = c("ID", "x", "y"), row.names = c(1L, 6L, 11L, 16L), class = "data.frame")
在数据框上使用重复的方法应该有效:
dat[!duplicated(dat),] # (equivalent here to dat[!duplicated(dat$ID),] ) ID x y 1 1 46 5 6 2 47 6 11 3 47 7 16 4 47 7