Learn R Programming

eye (version 1.2.1)

hyperop: Hyperopic eye data

Description

Pivot eye-related variables to two columns

Usage

hyperop(x, cols, eye = NULL)

Arguments

x

data frame

cols

columns which should be made "wide". Tidyselection supported

eye

eye column (default looking for "eye" or "eyes", all cases)

Value

A tibble, see also tibble::tibble

Details

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

See Also

About tidyselection

Examples

Run this code
# NOT RUN {
# 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"))


# }

Run the code above in your browser using DataLab