[R] search a value in variables dataset
ronggui
042045003 at fudan.edu.cn
Thu Oct 20 17:55:58 CEST 2005
======= 2005-10-20 22:50:07 ÄúÔÚÀ´ÐÅÖÐдµÀ£º=======
>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.
>
>Without having tested:
> with(my.reducedID, rownames(V1==0 & V5==14 & V6==2))
>
It doesn't work.
> with(my.reducedID, rownames(V1==0 & V5==14 & V6==2))
NULL
But the following does
> my.reducedID[with(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
>Uwe Ligges
>
>> Best, Muhammad Subianto
>>
>> ______________________________________________
>> R-help at 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 at 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
= = = = = = = = = = = = = = = = = = = =
2005-10-20
------
Deparment of Sociology
Fudan University
My new mail addres is ronggui.huang at gmail.com
Blog:http://sociology.yculblog.com
More information about the R-help
mailing list