Converts dataframe from long/tidy to wide format with NAs removed
This conversion is helpful mostly for repeated measures design, where
removing NA
s by participant can be a bit tedious.
It does not make sense to spread the dataframe to wide format when the
measure is not repeated, so if paired = TRUE
, spread
argument will be
ignored.
long_to_wide_converter( data, x, y, subject.id = NULL, paired = TRUE, spread = TRUE, ... )
data |
A dataframe (or a tibble) from which variables specified are to be taken. Other data types (e.g., matrix,table, array, etc.) will not be accepted. |
x |
The grouping (or independent) variable from the dataframe |
y |
The response (or outcome or dependent) variable from the
dataframe |
subject.id |
Relevant in case of a repeated measures or within-subjects
design ( |
paired |
Logical that decides whether the experimental design is
repeated measures/within-subjects or between-subjects. The default is
|
spread |
Logical that decides whether the dataframe needs to be
converted from long/tidy to wide (default: |
... |
Currently ignored. |
A dataframe with NA
s removed.
# for reproducibility library(ipmisc) set.seed(123) # repeated measures design long_to_wide_converter( data = bugs_long, x = condition, y = desire, subject.id = subject, paired = TRUE ) # independent measures design (spread argument is ignored) long_to_wide_converter( data = ggplot2::msleep, x = vore, y = brainwt, paired = FALSE, spread = FALSE )
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.