other_day: Transform Diary Data and Create a Next or Previous Day...

Description Usage Arguments Value Examples

View source: R/padis_specific_functions.R

Description

The function follows following rule: First, it treats each id separately. It then looks in the column days_in for each numeric value x that has a preceding or follwing lower or higher value y with a difference of x - y = 1 (e.g. if there is a 4, it searches for a 3 or a 5, depending on the setting of next_day). If it finds a preceding value y that is one smaller than the initial value x, it returns corresponding row-wise values from the columns variables and stores them as in a new variable.

Usage

1
2
3
other_day(data, id = "PAR.ID", days_in = "Day.DaysIn",
  variables = c("Day.Wellbeing", "Day.Closeness"), prefix = NULL,
  next_day = FALSE)

Arguments

data

The data frame that contains the variable

id

The ID variable of the participants

days_in

The variable identifying the day of each measurement. Must be numeric

variables

The variables that should be transformed to a next day variable

prefix

The prefix that is added to the names of the transformed variables. Default is NULL, which will set the prefix accoring to the next_day argument

next_day

Logical. If TRUE, the next day is returned. If FALSE, the previous day is returned

Value

Returns a data frame with the original variables as well as the transformed variables

Examples

1
2
3
data <- next_day_data
previous_day <- other_day(data)
next_day <- other_day(data, next_day = TRUE)

kthorstmann/padis documentation built on May 24, 2019, 5:01 a.m.