, .
n <- nrow(dat)
log1 <- 0 < dat$LocX & dat$LocX < 4 & 0 < dat$LocY & dat$LocY < 4
log2 <- c(FALSE, c(dat$LocX[-n] > 4 & dat$LocY[-n] > 4))
dat$Value <- as.integer(log1 & log2)
dat
:
dat <-
structure(list(Event = 1:8, LocX = c(6L, 3L, 3L, 1L, 7L, 1L,
8L, 1L), LocY = c(6L, 2L, 7L, 4L, 4L, 2L, 5L, 1L)), .Names = c("Event",
"LocX", "LocY"), class = "data.frame", row.names = c(NA, -8L))
source
share