Learn R Programming

eye (version 1.0.0)

eyes: Count patients and eyes

Description

Counts number of patients and right and left eyes. Columns are guessed.

Usage

eyes(x, id = NULL, eye = NULL, dropunknown = TRUE)

eyestr(x, ..., small_num = TRUE, para = FALSE, UK = FALSE)

Arguments

x

required. (data frame)

id

Patient identifying column, passed as (quoted) character

eye

Eye identifying column, passed as (quoted) character

dropunknown

introduces NA for values not recognized by recodeye

...

passed to eyes

small_num

If TRUE: writing numbers <= 12 as words

para

If TRUE: Adding "A total of" to comply with most journal standards and to avoid awkward long numbers.

UK

Logical, Use UK (English) style (TRUE) or USA (American) style (FALSE).

Value

eyes: Named integer vector with count of patients and eyes

eyestr: Character string - can be directly pasted into reports

Guessing

id and eye arguments overrule the name guessing for the respective columns (here, cases need to match)

For any below, cases are always ignored (column names can be in upper or lower case, as you please)

patient ID columns:

  • First, eyes is looking for names that contain both strings "pat" and "id" (the order doesn't matter)

  • Next, it will look for columns that are plainly called "ID"

  • Last, it will search for all names that contain either "pat" or "id"

eye variable column:

  • eyes primarily looks for columns called either "eye" or "eyes", and if they are not present, columns containing string "eye" (e.g., EyeName will be recognized)

Eye coding

The following codes are recognized:

  • integer coding 0:1 and 1:2, right eye being the lower number.

  • right eyes: c("r", "re", "od", "right") and

  • left eyes: c("l", "le", "os", "left") and

  • both eyes: c("b", "both", "ou")

If your eye column contains other values, they will be dropped to NA (dropunknown) or kept (and then only patients will be counted, because coding remains unclear). Recommend then to recode with recodeye

eyestr

eyestr is a wrapper around eyes. It parses the result into meaningful text, which can be #' readily pasted into reports with eyes_to_string under the hood. Arguments to eyes_to_string are passed via ...:

  • small_num If TRUE (default): numbers <= 12 as words

  • para If TRUE (not default): Adding "A total of" to comply with most journal standards and to avoid awkward long numbers.

  • UK TRUE: UK style (English) or FALSE (default): US style (American).

Examples

Run this code
# NOT RUN {
library(eyedata)
eyes(amd2)
library(eyedata)
eyestr(amd2, para = TRUE)
# }

Run the code above in your browser using DataLab