#300 1 3 10
#301 1 3 2
#437 1 3 9
#672 1 3 8
A.K.
- Original Message -
From: Rui Barradas
To: Noah Silverman
Cc: "R-help@r-project.org"
Sent: Friday, July 5, 2013 3:51 PM
Subject: Re: [R] Subset and order
Hello,
If time is one of the problems, precompute an ordered index
David Carlson tamu.edu> writes:
>
> It may be that single and efficient are opposing goals. Two steps
> lets you create the subset and then just order each query.
> Alternatively, if the data do not change often, create an ordered
> version and query that.
>
I don't know the data.table pack
[mailto:r-help-boun...@r-project.org] On Behalf Of Noah Silverman
Sent: Friday, July 5, 2013 2:47 PM
To: Rui Barradas
Cc: R-help@r-project.org
Subject: Re: [R] Subset and order
That would work, but is painfully slow. It forces a new sort of the
data with every query. I have 200,000 rows and need
Hello,
If time is one of the problems, precompute an ordered index, and use it
every time you want the df sorted. But that would mean you can't do it
in a single operation.
iord <- order(x$a)
subset(x[iord, ], b == 3)
Rui Barradas
Em 05-07-2013 20:47, Noah Silverman escreveu:
That would w
That would work, but is painfully slow. It forces a new sort of the data with
every query. I have 200,000 rows and need almost a hundred queries.
Thanks,
-N
On Jul 5, 2013, at 12:43 PM, Rui Barradas wrote:
> Hello,
>
> Maybe like this?
>
> subset(x[order(x$a), ], b == 3)
>
>
> Hope thi
Hello,
Maybe like this?
subset(x[order(x$a), ], b == 3)
Hope this helps,
Rui Barradas
Em 05-07-2013 20:33, Noah Silverman escreveu:
Hello,
I have a data frame with several columns.
I'd like to select some subset *and* order by another field at the same time.
Example:
a b c
1
Hello,
I have a data frame with several columns.
I'd like to select some subset *and* order by another field at the same time.
Example:
a b c
1 2 3
3 3 4
2 4 5
1 3 4
etc
I want to select all rows where b=3 and then order by a.
To
Hi Noah,
I think it is hard to say what is best without your real example. Is
the goal elegance or speed? I have not tried it, but if you are
ordering say 9/10 groups, I would think you are better off calling
order once, even though you will not use it for one group.
I also think if you are ord
can be done in one line, but it is annoying and ugly, so you probably
shouldn't be doing it that way:
>sleep[sleep$group == 1,] <-sleep[sleep$group == 1,][order(sleep[sleep$group ==
>1,1]),]
>sleep
extra group ID
1 -1.6 1 2
2 -1.2 1 4
3 -0.2 1 3
4 -0.1 1 5
50.0
Just write a function so that you have a "one-liner" in your script.
It will probably be a lot simpler than trying to type some convoluted
one-liner.
On Sat, May 12, 2012 at 2:58 PM, Noah Silverman wrote:
> Bernard,
>
> Thanks, but I can't take that shortcut.
>
> The data is an xts object, and I
Bernard,
Thanks, but I can't take that shortcut.
The data is an xts object, and I may not want to order every group. So, I need
a way to just order one group at a time.
Thoughts?
--
Noah Silverman
UCLA Department of Statistics
8208 Math Sciences Building
Los Angeles, CA 90095
On May 12, 2012
On 12-05-2012, at 20:04, Noah Silverman wrote:
> Is there a way to order data and subset it at the same time??
>
>
>
> I want to sort all the members of group A by their values in column 3. (I'll
> then do the same for each subsequent group.) This could be done in a loop
> building up anoth
Is there a way to order data and subset it at the same time??
I want to sort all the members of group A by their values in column 3. (I'll
then do the same for each subsequent group.) This could be done in a loop
building up another vector, but I like to avoid loops in R.
13 matches
Mail list logo