You could use the duplicated function maybe:

 mtest
     id time value
[1,]  1    3     1
[2,]  1    3     2
[3,]  1    2     3
[4,]  1    1     4
[5,]  2    1     5
[6,]  2    3     6
[7,]  2    3     7
[8,]  2    3     8

duplicated(mtest[,1:2])
[1] FALSE  TRUE FALSE FALSE FALSE FALSE  TRUE  TRUE

mtest[!duplicated(mtest[,1:2]),]
     id time value
[1,]  1    3     1
[2,]  1    2     3
[3,]  1    1     4
[4,]  2    1     5
[5,]  2    3     6

On 30.11.2012, at 17:15, Jessica Streicher wrote:

> Hello Bikek,
> 
> please use dput() next time to provide the data, its easier to use that.
> 
> also: looking at the data provided, how would you want to decide which value 
> of the non-unique times to retain? Just take the first one? They aren't all 
> the same.
> 
> On 30.11.2012, at 16:59, bibek sharma wrote:
> 
>> Hello user,
>> I have large data containing  subject id, time and response where
>> subjects are measured repeatedly. However some time are duplicates. I
>> only want data with unique time points per id. I mean if time is
>> repeated, then take only one.
>> Here is a sample data.
>> 
>> id   time    res
>> 1    2       0.64
>> 1    3       0.78
>> 1    3       6.5
>> 1    3       4.5
>> 1    4       4
>> 1    5       3.4
>> 2    10      5.7
>> 2    11      5.8
>> 2    11      9.3
>> 2    11      3.4
>> 2    12      3.4
>> 2    13      6.7
>> 3    3       5.6
>> 3    3       3.4
>> 3    4       2.3
>> 3    5       5.6
>> 3    12      9.8
>> 3    10      7
>> 3    24      6
>> 3    16      4
>> 
>> for 1st subject I want this,
>> 
>> id   time    res
>> 1    2       0.64
>> 1    3       0.78
>> 1    4       4
>> 1    5       3.4
>> Any suggestions are much appreciated!
>> Thanks,
>> Bikek
>> 
>> ______________________________________________
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
> 
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to