Learn R Programming

edl (version 1.1)

check: Remove empty cues and/or outcomes.

Description

Remove empty cues and/or outcomes.

Usage

check(data, rm = TRUE)

Arguments

data

Data frame with columns Cues and Outcomes.

rm

Logical: whether or not to remove empty strings. (Default TRUE).

Value

data frame or numeric vector (see details)

Details

When rm=FALSE the function returns a code for each row of the data frame indicating whether an empty cue or outcome was detected. The function may return the following values:

0

No empty cues and outcomes were detected in this row.

1

Empty cue(s) but not empty outcomes were detected in this row.

2

Empty outcome(s) but not empty cues were detected in this row.

3

Empty cue(s) AND empty outcome(s) were detected in this row.

Examples

Run this code
# NOT RUN {
test1 <- c("a_b", "a__b", "_a_b", "a_b_", "_a__b_", "___")
# }
# NOT RUN {
    # this returns an error:
    check(test1)
# }
# NOT RUN {
# data frame with cues and outcomes:
(dat <- data.frame(Cues=test1, Outcomes=sample(test1), stringsAsFactors=TRUE))
# remove empty:
check(dat)
# only indicating which rows contain empty cues/outcomes:
(test <- check(dat, rm=FALSE))
# check empty cues:
dat[test %in% c(1,3),]
# check empty outcomes:
dat[test %in% c(2,3),]

# }

Run the code above in your browser using DataLab