[prev in list] [next in list] [prev in thread] [next in thread]
List: r-help
Subject: Re: [R] Sum every n (4) observations by group
From: Rasmus Liland <jral () posteo ! no>
Date: 2021-12-21 1:19:03
Message-ID: YcErh5jZHAjVex5q () posteo ! no
[Download RAW message or body]
Dear Miluji,
I went through different combinations,
and find it elegant to sum the values
with respect to ID + High/Low Date
levels like if this was a list of
Dose/Material/Group experiments:
x[x$Date %in% c(4143, 4147),"j"] <-
tapply(x$Value, paste0(x$ID,
ifelse(x$Date>4143, 2, 1)), sum)
This way, you escape the «every 4th
observation» criterium, IMHO instead
«using» the dataframe in contrast to
creating new information or interpreting
the structure of the data frame ...
I'm sorry if this only creates confusion
and a «what is he talking about?!»
awkwardness by not answering the
question in a precise way ...
Best,
Rasmus
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic