Learn R Programming

DataCombine (version 0.2.21)

CasesTable: Create reports cases after listwise deletion of missing values for time-series cross-sectional data.

Description

Create reports cases after listwise deletion of missing values for time-series cross-sectional data.

Usage

CasesTable(data, GroupVar, TimeVar, Vars)

Arguments

data
a data frame with the full sample.
GroupVar
a character string specifying the variable in data which contains the group IDs.
TimeVar
an optional character string specifying the variable in data which contains the time variable.
Vars
a character vector with variables names from data for which you would like to listwise delete observations with missing values.

Value

If TimeVar is specified then a data frame is returned with three colums. One identifying the GroupVar and two others specifying each unique value of GroupVar's first and last observation time post-listwise deletion of missing values.If TimeVar is not specified, then a vector of unique GroupVar post-listwise deletion of missing values is returned.

Examples

Run this code
# Create dummy data
ID <- rep(1:4, 4)
time <- rep(2000:2003, 4)
a <- rep(c(1:3, NA), 4)
b <- rep(c(1, NA, 3:4), 4)
Data <- data.frame(ID, time, a, b)

# Find cases that have not been listwise deleted
CasesTable(Data, GroupVar = 'ID')
CasesTable(Data, GroupVar = 'ID', Vars = 'a')
CasesTable(Data, GroupVar = 'ID', TimeVar = 'time', Vars = 'a')


Run the code above in your browser using DataLab