Home
Blogs
Questions
Jobs
Monetize

Home

About Us

Blogs

Questions

Jobs

Monetize

Post Job

banner

Questions about rollapply

Read more about rollapply

python (12.9k questions)

javascript (9.2k questions)

reactjs (4.7k questions)

java (4.2k questions)

java (4.2k questions)

c# (3.5k questions)

c# (3.5k questions)

html (3.3k questions)

Questions - rollapply

How to flag the values of a column based on values of another column in R by using rollapply?

I have a data frame, like this: df <- data.frame (T = c(1:20), L = c(1,2,9,4,6,8,3,4,2,5,2,5,9,10,3,5,1,1,2,2)) I want to Flag a T value Ti (and also Ti−1 and Ti+1) if Li is bigger than 6 (i.e. ...
test-img

Faranak omidi

r

dplyr

zoo

rollapply

Votes: 0

Answers: 2

Latest Answer

Using rollapply - library(dplyr) library(zoo) df %>% mutate(flag = rollapply(L > 6, 3, any, fill = FALSE)) # T L flag #1 1 1 FALSE #2 2 2 TRUE #3 3 9 TRUE #4 4 4 TRUE #5 ...
test-img

Ronak Shah

Posts

Questions

Blogs

Jobs

The ultimate platform for coders and IT specialists

About

  • Company
  • Support

  • Platform

  • Terms & Conditions
  • Privacy statement
  • Cookie policy
  • Cookie option
  • OnlyCoders © 2025  |  All rights reserved