Re: [R] how to find "first" or "last" record after sort in R

2021-09-10 Thread Richard O'Keefe
Let's simplify this to consider a single vector, such as x <- c(1,1,1,2,2,3,3,3,3,4,5,5,5) in which equal elements are in contiguous blocks. > diff(x) [1] 0 0 1 0 1 0 0 0 1 1 0 0 Of course, there could be gaps, or the sequence might be descending instead of ascending. So > diff(x) != 0 We are nea

Re: [R] how to find "first" or "last" record after sort in R

2021-09-10 Thread Avi Gross via R-help
Excellent function to use, Terry. I note when I used it on a vector (in this case the first column of a data.frame, it accepted last=TRUE as well a fromlast=TRUE, which I did not see documented. Used on a data.frame, that change fails as function duplicated.data.frame only passes along the

Re: [R] Windows installation failed testing

2021-09-10 Thread Duncan Murdoch
On 10/09/2021 9:51 a.m., mario.corr...@croalliance.com wrote: Thanks Unfortunately we checked the PATH and is correctly set Any other suggestion? Other Windows users experiment the same problem? What error did you see in the output dir? Duncan Murdoch Mario -Original Message- [cut]

Re: [R] how to find "first" or "last" record after sort in R

2021-09-10 Thread Kai Yang via R-help
Thanks Therneau, duplicated() function works well. --- Kai On Friday, September 10, 2021, 05:13:47 AM PDT, Therneau, Terry M., Ph.D. wrote: I prefer the duplicated() function, since the final code will be clear to a future reader.   (Particularly when I am that future reader). last <

Re: [R] [External] Handling interrupts in long-running R functions

2021-09-10 Thread luke-tierney
Some variation of this might do it: tryCatch(for (i in seq_len(100)) Sys.sleep(1), interrupt = function(e) i) If you want the option to inspect and continue you would need to use withCallingHandlers and invoke a 'resume' restart. Best, luke On Fri, 10 Sep 2021, Ivan Krylo

[R] Handling interrupts in long-running R functions

2021-09-10 Thread Ivan Krylov
Hello everyone, I'm writing an R function that may be running for "long" periods of time (think tens of minutes), and I would like to be able to tell it: "please stop what you're doing and return the not-yet converged results as they are for inspection". The behaviour I'm striving for is 1) User

Re: [R] Windows installation failed testing

2021-09-10 Thread mario.corrado
Thanks Unfortunately we checked the PATH and is correctly set Any other suggestion? Other Windows users experiment the same problem? Mario -Original Message- [cut] The current working directory is the default output directory. You will see a directory produced there containing the resu

Re: [R] how to find "first" or "last" record after sort in R

2021-09-10 Thread Therneau, Terry M., Ph.D. via R-help
I prefer the duplicated() function, since the final code will be clear to a future reader. (Particularly when I am that future reader). last <- !duplicated(mydata$ID, fromLast=TRUE) # point to the last ID for each subject mydata$data3[last] <- NA Terry T. (I read the list once a day in dige