checkins_in_interval: Get the checkins in an interval

View source: R/checkin.r

checkins_in_intervalR Documentation

Get the checkins in an interval

Description

This function filters the input data frame such that the output is a similar data frame where all entries are in the specified period between start and end. The start_loc and end_loc parameters specify whether or not last observations should be carried forward. If start_loc is TRUE then a checkin occuring before the interval will be carried forward so that the location appears in the output at the beginning of the interval. If end_loc is TRUE then a checkin is carried forward to the end of the interval.

Usage

checkins_in_interval(x, time, start, end, start_loc = TRUE, end_loc = TRUE)

Arguments

x

the data frame of checkins.

time

the column denoting the timestamp.

start

the beginning of the interval.

end

the end of the interval.

start_loc

should the starting location be included? Default TRUE.

end_loc

should the end location be included? Default TRUE.

Examples

 library(dplyr)
 library(lubridate)
 data(checkins)

 x <- checkins %>%
   filter(id == 335) %>%
   arrange(timestamp)

 start <- x$timestamp[1]
 minute(start) <- 0
 second(start) <- 0

 end <- start + hours(1) - seconds(1)
 checkins_in_interval(x, "timestamp", start, end)


kaneplusplus/checkin documentation built on Aug. 1, 2022, 1:11 p.m.