Re: [R] Trying to understand how to sort a DF on two columns

2019-08-14 Thread Stephen Ellison
> I want to sort a DF, temp, on two columns, patid and time. I have searched > the internet and found code that I was able to modify to get my data sorted. > Unfortunately I don't understand how the code works. I would appreciate it > if someone could explain to me how the code works. Among other

Re: [R] Trying to understand how to sort a DF on two columns

2019-08-13 Thread Rui Barradas
Hello, Though good answers were already given, I would like to say something. 1. If you are lazy (typing), use with, if you prefer to play safe, don't. I am lazy many times, but in interactive mode only. 2. I find it better in the long run *not* to take advantage of R's one-liners, they tend

Re: [R] Trying to understand how to sort a DF on two columns

2019-08-12 Thread Jeff Newmiller
With this as an example, no wonder you don't understand it. This is horrible. `with` is very much like the `subset` function... it alleviates the need to re-type the containing object name repeatedly. data4xsort <- temp[ with( temp, order( patid, time ) ), ] is the same as data4xsort <- temp[

Re: [R] Trying to understand how to sort a DF on two columns

2019-08-12 Thread Sorkin, John
Bert, Thank you for your reply (and the many other questions to the list that you answer). I understand how order works when ordering based on a single column. What I don’t understand is how the code I included with my email works. I believe my problem is a lack of understanding of what with

Re: [R] Trying to understand how to sort a DF on two columns

2019-08-12 Thread David Winsemius
On 8/12/19 7:20 PM, Sorkin, John wrote: I want to sort a DF, temp, on two columns, patid and time. I have searched the internet and found code that I was able to modify to get my data sorted. Unfortunately I don't understand how the code works. I would appreciate it if someone could explain

Re: [R] Trying to understand how to sort a DF on two columns

2019-08-12 Thread Bert Gunter
https://stackoverflow.com/questions/2315601/understanding-the-order-function Do a web search on "How does order() work R" or similar for more. I can't explain with() any better than the docs: saying that it evaluates the expression argument in the data argument environment -- a data frame for

[R] Trying to understand how to sort a DF on two columns

2019-08-12 Thread Sorkin, John
I want to sort a DF, temp, on two columns, patid and time. I have searched the internet and found code that I was able to modify to get my data sorted. Unfortunately I don't understand how the code works. I would appreciate it if someone could explain to me how the code works. Among other