Re: [R] Help needed with aggregate or other solution

2017-10-27 Thread Anthoni, Peter (IMK)
Hi Thomas, Would this work: res1=aggregate(dta[,"fcst"],by=list(basistime=dta[,"basistime"]),FUN=max) mm=match(paste(res1[,"basistime"],res1[,"x"]),paste(dta[,"basistime"],dta[,"fcst"])) dta[mm,] > dta[mm,] date basistime fcst usgs 20 2012-01-30 12:00:00 2012-01-25

Re: [R] Help needed with aggregate or other solution

2017-10-26 Thread Daniel Nordlund
On 10/26/2017 4:58 AM, Thomas Adams wrote: Hi Jeff, Thank you for the suggestions -- I appreciate your help. Unfortunately, the result2 has two problems... (1) there are now 3 date columns (it looks like 2 cols are merged into 1 col) (2) the output rows should not have any of the basistime

Re: [R] Help needed with aggregate or other solution

2017-10-26 Thread Jeff Newmiller
On Thu, 26 Oct 2017, Thomas Adams wrote: Hi Jeff, Thank you for the suggestions -- I appreciate your help. Unfortunately, the result2 has two problems... (1) there are now 3 date columns (it looks like 2 cols are merged into 1 col) No, there are two date columns. Result2 includes the

Re: [R] Help needed with aggregate or other solution

2017-10-26 Thread Thomas Adams
Hi Jeff, Thank you for the suggestions -- I appreciate your help. Unfortunately, the result2 has two problems... (1) there are now 3 date columns (it looks like 2 cols are merged into 1 col) (2) the output rows should not have any of the basistime dates repeated (maybe I misstated the problem);

Re: [R] Help needed with aggregate or other solution

2017-10-25 Thread Jeff Newmiller
Thanks for the dput... reproducible example of split-apply-combine ### dta <- structure(list(date = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L,

[R] Help needed with aggregate or other solution

2017-10-25 Thread Thomas Adams
Hello all! I've been struggling with is for many hours today; I'm close to getting what I want, but not close enough... I have a dataframe consisting of two date-time columns followed by two numeric columns. what I need is the max value (in the first numeric column) based on the 2nd date-time