[R] Querying a data frame or data.table
David Winsemius
dwinsemius at comcast.net
Fri Dec 3 14:52:16 CET 2010
On Dec 3, 2010, at 3:44 AM, Michael Bedward wrote:
> Sounds just like the subset function (?)
>
> x <- as.data.frame(matrix(sample(5, 100, rep=TRUE), ncol=10))
> subset(x, )
With data,table:
require(data.table)
> xd <- as.data.table(x)
> xd[ V1 > 3 & V2 < 5 , ]
V1 V2 V3 V4 V5 V6 V7 V8 V9 V10
[1,] 4 2 4 1 2 3 1 3 2 4
[2,] 4 1 2 2 4 2 3 2 4 3
[3,] 5 1 1 5 4 5 4 1 1 3
>
> Michael
>
> On 3 December 2010 19:05, Santosh Srinivas
> <santosh.srinivas at gmail.com> wrote:
>> Hello Group,
>>
>> Is there an easy way to query a data.frame or data.table (this is
>> fast!) for multiple conditions?
>> I don't want to use a SQL kind of statement.
>>
>> I am looking for something like a subset with multiple conditions.
>>
>> Any tips of the like the binary search methodology used for
>> data.table
>> would also help.
>>
>> Thanks in advance.
>> S
>
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list