Re: [R] search a value in variables dataset

From: Muhammad Subianto <subianto_at_gmail.com>
Date: Fri 21 Oct 2005 - 01:32:57 EST

Dear All,
Perfect. Thanks you very much for your help.

Best, Muhammad Subianto

 >>my.reducedID<-read.table(file.choose())
 >>head(my.reducedID)
 >
 >     V1 V2 V3 V4 V5 V6 V7 V8 V9
 >[1,]  1  0  0  1 14  3  1  0  2
 >[2,]  2  0  0  1 14  3  1  0  2
 >[3,]  0  1  0  1 14  2  1  0  2
 >[4,]  0  0  1  1 14  3  1  0  2
 >[5,]  0  1  1  0 14  2  1  0  2
 >[6,]  0  0  0  1 14  3  1  0  2
 >
 >>attach(my.reducedID)
 >>my.reducedID[(V1==0 & V5==14 & V6==2),]
 >
 >      V1 V2 V3 V4 V5 V6 V7 V8 V9
 >[3,]   0  1  0  1 14  2  1  0  2
 >[5,]   0  1  1  0 14  2  1  0  2
 >[29,]  0  0  0  1 14  2  1  0  2
 >

######## OR ##########

 >my.reducedID[ my.reducedID[,1]==0 & my.reducedID[,5]==14 &
 >my.reducedID[,6]==2, ]
 >


On this day 20/10/2005 03:59 PM, Muhammad Subianto wrote:
> Dear R-list,
> I have a dataset, say (the real dataset is 20 columns,110200 rows).
>
> > my.reducedID
> V1 V2 V3 V4 V5 V6 V7 V8 V9
> [1,] 1 0 0 1 14 3 1 0 2
> [2,] 2 0 0 1 14 3 1 0 2
> [3,] 0 1 0 1 14 2 1 0 2
> [4,] 0 0 1 1 14 3 1 0 2
> [5,] 0 1 1 0 14 2 1 0 2
> [6,] 0 0 0 1 14 3 1 0 2
> [7,] 0 0 0 1 0 3 1 0 2
> [8,] 0 0 0 1 1 3 1 0 2
> [9,] 0 0 0 1 2 3 1 0 2
> [10,] 0 0 0 1 3 3 1 0 2
> [11,] 0 0 0 1 4 3 1 0 2
> [12,] 0 0 0 1 5 3 1 0 2
> [13,] 0 0 0 1 6 3 1 0 2
> [14,] 0 0 0 1 7 3 1 0 2
> [15,] 0 0 0 1 8 3 1 0 2
> [16,] 0 0 0 1 9 3 1 0 2
> [17,] 0 0 0 1 10 3 1 0 2
> [18,] 0 0 0 1 11 3 1 0 2
> [19,] 0 0 0 1 12 3 1 0 2
> [20,] 0 0 0 1 13 3 1 0 2
> [21,] 0 0 0 1 15 3 1 0 2
> [22,] 0 0 0 1 16 3 1 0 2
> [23,] 0 0 0 1 17 3 1 0 2
> [24,] 0 0 0 1 18 3 1 0 2
> [25,] 0 0 0 1 19 3 1 0 2
> [26,] 0 0 0 1 20 3 1 0 2
> [27,] 0 0 0 1 14 0 1 0 2
> [28,] 0 0 0 1 14 1 1 0 2
> [29,] 0 0 0 1 14 2 1 0 2
> [30,] 0 0 0 1 14 4 1 0 2
> >
>
> I want to search a value in variables, say V1=0, V5=14 and V6=2.
> The result should look like
> V1 V2 V3 V4 V5 V6 V7 V8 V9
> [3,] 0 1 0 1 14 2 1 0 2
> [5,] 0 1 1 0 14 2 1 0 2
> [29,] 0 0 0 1 14 2 1 0 2
>
> I can do this with: my.reducedID[c(3,5,29),]
> Because I have very large dataset I can not make this manual.
> Then I need the ID of row did not change, I mean like,
> [3,]
> [5,]
> [29,]
> In dataset this is about ID our customers.
> I was wondering if anyone give me a trick to make simple.
> Thanks you very much for any suggestions.
>
> Best, Muhammad Subianto
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
>
https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Oct 21 02:59:36 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 19:13:19 EST