Hi, It's my problem, supppose that we have a data.frame: t a b c 1 1 1 1 2 0 1 1 3 1 1 1 4 0 0 0 5 1 0 1 6 0 1 0 7 1 1 1 8 0 1 0 I need extract duplicat row i.e i nedd frame like this a b c 3 1 1 1 8 0 1 0 I try use subset(t, duplicated(t)) and t[duplicated(t), ] but this command return a b c 3 1 1 1 7 1 1 1 8 0 1 0 Best Marcin M. -- View this message in context: http://r.789695.n4.nabble.com/Removing-all-duplicate-row-except-by-one-tp3736949p3736949.html Sent from the R help mailing list archive at Nabble.com.
m.marcinmichal <m.marcinmichal <at> gmail.com> writes:> > Hi, > It's my problem, supppose that we have a data.frame: >-snip- You should avoid using t as a variable name since its an important R function!> I need extract duplicat row i.e i nedd frame like this > > a b c > 3 1 1 1 > 8 0 1 0 >not sure if this will get you there but if you data is in a variable named dat...> unique(dat[duplicated(dat),])a b c 3 1 1 1 8 0 1 0> I try use subset(t, duplicated(t)) and t[duplicated(t), ] but this command > return > > a b c > 3 1 1 1 > 7 1 1 1 > 8 0 1 0 > > Best > > Marcin M. > > -- > View this message in context:http://r.789695.n4.nabble.com/Removing-all-duplicate-row-except-by-one-tp3736949p3736949.html> Sent from the R help mailing list archive at Nabble.com. > >
On 12/08/11 07:37, m.marcinmichal wrote:> Hi, > It's my problem, supppose that we have a data.frame: > > t > a b c > 1 1 1 1 > 2 0 1 1 > 3 1 1 1 > 4 0 0 0 > 5 1 0 1 > 6 0 1 0 > 7 1 1 1 > 8 0 1 0 > > I need extract duplicat row i.e i nedd frame like this > > a b c > 3 1 1 1 > 8 0 1 0 > > I try use subset(t, duplicated(t)) and t[duplicated(t), ] but this command > return > > a b c > 3 1 1 1 > 7 1 1 1 > 8 0 1 0unique(t[duplicated(t),]) BTW "t" is not a good name for an object since it is the name of a base function in R (the transpose function). cheers, Rolf Turner