Description Usage Arguments Value Examples
View source: R/long_to_wide_converter.R
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.
1 2 3 4 5 6 7 8 9 |
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 while respecting the
between-or-within-subjects nature of the dataset.
# 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 )
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #> # A tibble: 88 x 5
#> rowid HDHF HDLF LDHF LDLF
#> <int> <dbl> <dbl> <dbl> <dbl>
#> 1 1 10 9 6 6
#> 2 3 10 10 10 5
#> 3 4 9 6 9 6
#> 4 5 8.5 5.5 6.5 3
#> 5 6 3 7.5 0.5 2
#> 6 7 10 10 10 10
#> 7 8 10 9 10 10
#> 8 9 10 6 9.5 9.5
#> 9 11 0 0 2.5 0
#> 10 12 10 8.5 7.5 9.5
#> # ... with 78 more rows
|
# independent measures design long_to_wide_converter( data = ggplot2::msleep, x = vore, y = brainwt, paired = FALSE )
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #> # A tibble: 51 x 3
#> rowid vore brainwt
#> <int> <fct> <dbl>
#> 1 3 carni 0.07
#> 2 4 carni 0.0108
#> 3 5 carni 0.0256
#> 4 7 carni 0.325
#> 5 9 carni 0.0125
#> 6 12 carni 0.157
#> 7 17 carni 0.0175
#> 8 18 carni 0.0445
#> 9 19 carni 0.0504
#> 10 21 herbi 0.423
#> # ... with 41 more rows
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.