this question has answer here:
i build on question similar remove rows data frame row match string
for example:
a,b,org.id 4,3,foo 2,3,bar 2,4,bar 7,5,zap 7,4,zap 7,3,zap how return dataframe excludes rows org.id same row above?
a,b,org.id 4,3,foo 2,3,bar 7,5,zap guess: perhaps melt() or cast() functions trick. (i know how in excel, have create new dataframe , if[a2=a1,0,a2].)
the question similar subtract previous row of data id same row above in sql.
you can try duplicated
df1[!duplicated(df1$org.id),] # b org.id #1 4 3 foo #2 2 3 bar #4 7 5 zap or using unique by option
library(data.table) unique(setdt(df1), by='org.id')
Comments
Post a Comment