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] separate and gather functions

2019-08-12 Thread reichmanj
William Yes that works a little better as I don’t have to create notional variables. Thank you Jeff From: William Dunlap Sent: Monday, August 12, 2019 6:46 PM To: Jeff Reichman Cc: r-help@r-project.org Subject: Re: [R] separate and gather functions This one uses only core R

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

Re: [R] separate and gather functions

2019-08-12 Thread William Dunlap via R-help
This one uses only core R functions. Does that count toward "elegance"? > # your data, I assume, in a form one can copy and paste into R > d <- data.frame(stringsAsFactors = FALSE, Col1 = c("Agency A", "Agency B", "Agency C"), Col2 = c("Function1, Function2, Function3, Function4",

[R] separate and gather functions

2019-08-12 Thread reichmanj
R-Help Forum I have a data set from which I have extracted two columns Column 1 is a listing of Federal agencies and Column 2 lists functions like this Col1 Col2 Agency A Function1, Function2, Function3, Function4 Agency B Function2,

Re: [R] vectorizing the integrate function

2019-08-12 Thread ravi via R-help
Hi all,I would like to thank every one who has responded to my question. I have received valuable help.Linus, the function that I gave here is just a toy function. I think that is possible even to find an analytical solution. I chose that just to include many constant parameters. I wanted to