eyes: Count patients and eyes

Description Usage Arguments Value Column guessing Eye coding eyestr Examples

View source: R/eyes.R

Description

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

Usage

1
2
3
eyes(x, id_col = NULL, eye_col = NULL, dropunknown = TRUE, details = FALSE)

eyestr(x, ..., english = "small", caps = FALSE)

Arguments

x

required. (data frame)

id_col

Subject identifying column, passed as (quoted) character Can also be abbreviated to "id" as per partial matching

eye_col

Eye identifying column, passed as (quoted) character. Can also be abbreviated to "eye" as per partial matching

dropunknown

introduces NA for values not recognized by recodeye

details

if TRUE, will add information about which and how many subjects have only one eye or both included, and provide a list of subject IDs for each

...

passed to eyes

english

Which numbers to be written in plain english: choose "small" for numbers till 12, "all" (all numbers), or "none" (or any other string!) for none

caps

if TRUE, first number will have capital first letter

Value

List (of class "eyes" with count of patients and eyes if "details = TRUE", an list of class "eyes_details" will be returned

eyestr: Character string - can be directly pasted into reports

Column guessing

id_col and eye_col arguments overrule the name guessing for the respective columns (here, cases need to match). Both arguments can be abbreviated (id or eye) as per partial argument name matching.

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

patient ID columns:

eye column:

Eye coding

The following codes are recognized: (change this with set_eye_strings)

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 creates a string which can be pasted into reports. It currently only supports "x eyes of n patient(s)" This is a limitation, but I guess in the vast majority of cases will be "correct". To use for other categories (e.g., "people" or "participants"), use eyes(...)[1]

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
library(eyedata)
eyes(amd2)

## If you code your eyes with different strings,
## e.g., because you are using a different language,
## you can change this either with `set_eye_strings`
set_eye_strings(right = c("droit", "od"), left = c("gauche", "og"))

## restore defaults with
set_eye_strings()
# Examples for the usage of eyestr
eyestr(amd2)

set.seed(1)
ls_dat <-
  lapply(c(1, 12, 13),
    function(x) data.frame(id = as.character(1:x),
                           eye = sample(c("r", "l"), x, replace = TRUE)))

lapply(ls_dat, eyestr, english = "small")
lapply(ls_dat, eyestr, english = "all")
lapply(ls_dat, eyestr, english = "all", caps = TRUE)
lapply(ls_dat, eyestr, english = "none")
lapply(ls_dat, eyestr, english = "none")

tjebo/eye documentation built on Jan. 24, 2022, 8:34 p.m.