View source: R/cm_code.blank.R
cm_code.blank | R Documentation |
Transform codes with any binary operator combination.
cm_code.blank(x2long.obj, combine.code.list, rm.var = NULL, overlap = TRUE)
x2long.obj |
An object from |
combine.code.list |
A list of named character vectors of at least two code column names to combine. |
rm.var |
Name of the repeated measures column. |
overlap |
logical, integer or character of binary operator + integer.
If |
Returns a dataframe with transformed occurrences of supplied overlapping codes added.
For most jobs cm_code.transform
will work. This
adds a bit of flexibility in exclusion and partial matching. The code column
must be named "code"
and your start and end columns must be named
"start"
and "end"
.
cm_range2long
,
cm_time2long
,
cm_df2long
,
cm_code.overlap
,
cm_code.combine
,
cm_code.exclude
,
cm_code.transform
## Not run:
foo <- list(
AA = qcv(terms="1:10"),
BB = qcv(terms="1:2, 3:10, 19"),
CC = qcv(terms="1:3, 5:6")
)
foo2 <- list(
AA = qcv(terms="4:8"),
BB = qcv(terms="1:4, 10:12"),
CC = qcv(terms="1, 11, 15:20"),
DD = qcv(terms="")
)
## Single occurrence version
(x <- cm_range2long(foo))
cm_code.blank(x, combine.code.list = list(ABC=qcv(AA, BB, CC)),
overlap = "!=1")
## Repeated measures version
(z <- cm_range2long(foo, foo2, v.name="time"))
cm_code.blank(z, combine.code.list = list(ABC=qcv(AA, BB, CC)),
rm.var = "time", overlap = "!=1")
cm_code.blank(z, combine.code.list = list(AB=qcv(AA, BB)),
rm.var = "time", overlap = TRUE)
cm_code.blank(z, combine.code.list = list(AB=qcv(AA, BB)),
rm.var = "time", overlap = FALSE)
cm_code.blank(z, combine.code.list = list(AB=qcv(AA, BB)),
rm.var = "time", overlap = ">1")
cm_code.blank(z, combine.code.list = list(AB=qcv(AA, BB)),
rm.var = "time", overlap = "==2")
## Notice `overlap = "==2"` above is identical to `cm_code.overlap`
cm_code.overlap(z, overlap.code.list = list(AB=qcv(AA, BB)),
rm.var = "time")
#WITH cm_time2long
x <- list(
transcript_time_span = qcv(00:00 - 1:12:00),
A = qcv(terms = "2.40:3.00, 5.01, 6.02:7.00, 9.00"),
B = qcv(terms = "2.40, 3.01:3.02, 5.01, 6.02:7.00, 9.00,
1.12.00:1.19.01"),
C = qcv(terms = "2.40:3.00, 5.01, 6.02:7.00, 9.00, 17.01")
)
y <- list(
transcript_time_span = qcv(00:00 - 1:12:00),
A = qcv(terms = "2.40:3.00, 5.01, 6.02:7.00, 9.00"),
B = qcv(terms = "2.40, 3.01:3.02, 5.01, 6.02:7.00, 9.00,
1.12.00:1.19.01"),
C = qcv(terms = "2.40:3.00, 5.01, 6.02:7.00, 9.00, 17.01")
)
dat <- cm_time2long(x, y, v.name="time")
head(dat, 10)
out <- cm_code.blank(dat, combine.code.list = list(ABC=qcv(A, B, C)),
rm.var = "time", overlap = "!=1")
head(out)
plot(out)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.