Learn R Programming

Actigraphy (version 1.4.0)

fda.matchid: Match IDs from Clinical and Actigraph Data

Description

A function used to match actigraphy data and clinical covariates by subject IDs and return a list of the data combined by IDs. Only the subjects with both actigraphy and covariate data will be returned by this function.

Usage

fda.matchid(mat, acov, type, grouplab)

Arguments

mat

A data frame with the rows being the time and the columns being the activity, with the column names being the subjects.

acov

A two column data frame that contains only subject IDs and a covariate of interest, respectively.

type

A string specifying either "contin" for continuous and "factor" for categorical covariates.

grouplab

A vector of names of the categories if type is TRUE.

Value

A list consisting of two components as follows:

mat

A matrix where rows represent the time, columns are the samples, and the column names are the subjects.

cov

A two column matrix that contains the actigraphy data and clinical covariates.

Details

Note: Only the subjects with both actigraphy and covariate data will be returned by this function.

Examples

Run this code
# NOT RUN {
	data(act_29pt)
	data(clinic_29pt_ahi)
	
	data <- act_29pt
	ahi <- clinic_29pt_ahi
	
	### Example 1: Continuous Covariate
	matchida  <- fda.matchid(data, ahi, "contin")
	
	
	### Example 2: Categorical Covariate
	ahi$ahicat <- as.factor(
		ifelse(ahi$AHI >= 0 & ahi$AHI <= 5, 1,
		ifelse(ahi$AHI > 5 & ahi$AHI <= 15, 2,
		ifelse(ahi$AHI > 15 & ahi$AHI <= 30, 3,
		ifelse(ahi$AHI > 30, 4, 0))))
	)
	
	matchidb  <- fda.matchid(data, ahi[,-2], "factor", 
			c("normal", "mild", "moderate", "severe"))
# }

Run the code above in your browser using DataLab