Learn R Programming

qdap (version 1.3.5)

cm_df2long: Transform Codes to Start-End Durations

Description

Transforms the range coding structure(s) from cm_df.temp (in list format) into a data frame of start and end durations in long format.

Usage

cm_df2long(df.temp.obj, v.name = "variable", list.var = TRUE,
  code.vars = NULL, no.code = NA, add.start.end = TRUE,
  repeat.vars = NULL, rev.code = FALSE)

Arguments

df.temp.obj
A character vector of names of object(s) created by cm_df.temp, a list of cm_df.temp created objects or a data frame created by
v.name
An optional name for the column created for the list.var argument.
list.var
logical. If TRUE creates a column for the data frame created by each time.list.
code.vars
A character vector of code variables. If NULL uses all variables from the first column after the column named word.num.
no.code
The value to assign to no code; default is NA.
add.start.end
logical. If TRUE adds a column for start and end times.
repeat.vars
A character vector of repeated/stacked variables. If NULL uses all non code.vars variables.
rev.code
logical. If TRUE reverses the order of code.vars and no.code variables.

Value

  • Generates a data frame of start and end times for each code.

References

Miles, M. B. & Huberman, A. M. (1994). An expanded sourcebook: Qualitative data analysis. 2nd ed. Thousand Oaks, CA: SAGE Publications.

See Also

cm_time2long, cm_range2long, cm_df.temp

Examples

Run this code
codes <- qcv(dc, sf, wes, pol, rejk, lk, azx, mmm)
x1 <- cm_df.temp(DATA, "state", codes)
head(x1)

#empty code matrix
out1 <- cm_df2long(x1,  code.vars = codes)
head(out1, 15)

#fill it randomly
x1[, 7:14] <- lapply(7:14,  function(i) sample(0:1, nrow(x1), TRUE))
out2 <- cm_df2long(x1,  code.vars = codes)
head(out2, 15)
plot(out2)

Run the code above in your browser using DataLab