[R] (almost) rolling function or fill?
bgunter@4567 @end|ng |rom gm@||@com
Mon Jun 8 23:00:42 CEST 2020
This is a plain text list. Your html post was completely mangled. Re-post
in plain text, please.
"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Mon, Jun 8, 2020 at 1:08 PM Andras Farkas via R-help <
r-help using r-project.org> wrote:
> please see if you have a thought on how to achieve the following:
> we have:
> the idea I have difficulty wrapping my head around is to do the following:
> I need the system to look at df$a by row (lets call it the index row) and
> look at df$b and df$c 1 row before the given row in df$a (lets call it
> index row -1) and evaluate if the index row value in df$a falls into the
> range (>= and <=) of the index row -1 values in df$b and df$c. If it does,
> then copy over the index row -1 values in df$b and df$c into the index row
> in df$b and df$c, if not place an NA in both cells of the index row in df$b
> and df$c.
> 1. the date value in df$a is between df$b and df$c so we can copy
> the values in df$b and df$c into df$b and df$c2. the date
> value in df$a is between df$b and df$c (as we copied it in in step
> 1) so we can copy the values in df$b and df$c into df$b and
> df$c3. the date value in df$a is NOT between df$b and df$c
> (as we copied it in in step 2) so we can place NA in df$b and df$c
> also would like to do this going up, too, similar to fill(...,"downup").
> On the end we would want to have this:
> much appreciate any help you could provide.
> [[alternative HTML version deleted]]
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.
[[alternative HTML version deleted]]
More information about the R-help