hyperop {eye} | R Documentation |
Pivot eye-related variables to two columns
hyperop(x, cols, eye = NULL)
x |
data frame |
cols |
columns which should be made "wide". Tidyselection supported |
eye |
eye column (default looking for "eye" or "eyes", all cases) |
Basically the opposite of myop()
- a slightly intelligent
wrapper around tidyr::pivot_longer()
and tidyr::pivot_wider()
Will find the eye column, unify the codes for the eyes (all to "r" and "l")
and pivot the columns wide, that have been specified in "cols".
Good names and tidy data always help!
For more information about shaping data and good names, see vignette("eye")
,
or ?blink
or ?myop
A tibble, see also tibble::tibble
# Example to clean a bit messy data frame
iopva <- data.frame(
id = c("a", "e", "j", "h"),
va_r = c(37L, 36L, 33L, 38L),
iop_r = c(38L, 40L, 33L, 34L),
va_l = c(30L, 39L, 37L, 40L),
iop_l = c(31L, 34L, 33L, 31L)
)
myop_iop <- myop(iopva)
hyperop(myop_iop, cols = matches("va|iop"))