data_nr_calc: Calculate data number

Description Usage Arguments Details

Description

This function takes a sema dataset (must contain a variable sema_id and rownr) and calculates 'datanr', a survey number variable tracking only surveys with data for each participant. This is useful if you want to time-lag using all available data (though of course this can mean that you are lagging across larger time gaps for some participants than others or on some days). This variable is calculated when the clean_sema function is initially called, but you can also call it directly afterwards if you remove additional data (for example, removing surveys where responsecount is too low)

Usage

1
data_nr_calc(semadata)

Arguments

semadata

An R dataframe containing both sema_id and rownr variables (most likely, a sema dataset -after- processing with clean_sema)

Details

Note that this will overwrite the previous version of datanr, so if you want to keep that variable for some reason, (for instance, you want to keep absolute data number separate from data number after surveys with too few responses are removed) then simple copy datanr into a new variable before using this function (e.g. mydata$old_data_nr <- mydata$datanr), then use this function.


seanchrismurphy/cleansema documentation built on May 23, 2019, 9:34 a.m.