The functions toWide(), toLong(), toCompiled() toRaw() and toTabular() converts the data into various formats.

toWide(w)

toLong(w)

toCompiled(w)

toRaw(w)

toTabular(w)

Arguments

w

An instance of an ANOFA object.

Value

a data frame in the requested format.

Details

The classification of a set of $n$ participants can be given using many formats. One basic format (called wide herein) has $n$ lines, one per participants, and category names assigned to each. Another format (called compiled herein) is to have a list of all the categories and the number of participants falling in each cells. This last format is typically much more compact (if there are 6 categories, the data are all contained in six lines). However, we fail to see each individual contributing to the counts. See the vignette DataFormatsForFrequencies for more. A third possible format (called raw herein) put one column per category and 1 is the observation matches this category, 0 otherwise. This format results in $n$ lines, one participants, and as many columns are there are categories. Lastly, a fourth format (called long herein) as, on a line, the factor name and the category assigned in that factor. If there are $f$ factors and $n$ participants, the data are in $f*n$ lines.

See the vignette DataFormatsForFrequencies for more.

Examples


# The minimalExample contains $n$ of 20 participants categorized according
# to two factors $f = 2$, namely `Intensity` (three levels) 
# and Pitch (two levels) for 6 possible cells.
minimalExample
#>   Intensity Pitch Frequency
#> 1       Low  Soft         2
#> 2    Medium  Soft         3
#> 3      High  Soft         5
#> 4       Low  Hard         4
#> 5    Medium  Hard         2
#> 6      High  Hard         4

# Lets incorporate the data in an anofa data structure
w <- anofa( Frequency ~ Intensity * Pitch, minimalExample )

# The data presented using various formats looks like
toWide(w)
#>    Intensity Pitch
#> 1        Low  Soft
#> 2        Low  Soft
#> 3     Medium  Soft
#> 4     Medium  Soft
#> 5     Medium  Soft
#> 6       High  Soft
#> 7       High  Soft
#> 8       High  Soft
#> 9       High  Soft
#> 10      High  Soft
#> 11       Low  Hard
#> 12       Low  Hard
#> 13       Low  Hard
#> 14       Low  Hard
#> 15    Medium  Hard
#> 16    Medium  Hard
#> 17      High  Hard
#> 18      High  Hard
#> 19      High  Hard
#> 20      High  Hard
# ... has 20 lines ($n$) and 2 columns ($f$)

toLong(w)
#>    Id    Factor  Level
#> 1   1 Intensity    Low
#> 2   1     Pitch   Soft
#> 3   2 Intensity    Low
#> 4   2     Pitch   Soft
#> 5   3 Intensity Medium
#> 6   3     Pitch   Soft
#> 7   4 Intensity Medium
#> 8   4     Pitch   Soft
#> 9   5 Intensity Medium
#> 10  5     Pitch   Soft
#> 11  6 Intensity   High
#> 12  6     Pitch   Soft
#> 13  7 Intensity   High
#> 14  7     Pitch   Soft
#> 15  8 Intensity   High
#> 16  8     Pitch   Soft
#> 17  9 Intensity   High
#> 18  9     Pitch   Soft
#> 19 10 Intensity   High
#> 20 10     Pitch   Soft
#> 21 11 Intensity    Low
#> 22 11     Pitch   Hard
#> 23 12 Intensity    Low
#> 24 12     Pitch   Hard
#> 25 13 Intensity    Low
#> 26 13     Pitch   Hard
#> 27 14 Intensity    Low
#> 28 14     Pitch   Hard
#> 29 15 Intensity Medium
#> 30 15     Pitch   Hard
#> 31 16 Intensity Medium
#> 32 16     Pitch   Hard
#> 33 17 Intensity   High
#> 34 17     Pitch   Hard
#> 35 18 Intensity   High
#> 36 18     Pitch   Hard
#> 37 19 Intensity   High
#> 38 19     Pitch   Hard
#> 39 20 Intensity   High
#> 40 20     Pitch   Hard
# ... has 40 lines ($n \times f$) and 3 columns (participant's `Id`, `Factor` name and `Level`)

toRaw(w)
#>    Low Medium High Soft Hard
#> 1    1      0    0    1    0
#> 2    1      0    0    1    0
#> 3    0      1    0    1    0
#> 4    0      1    0    1    0
#> 5    0      1    0    1    0
#> 6    0      0    1    1    0
#> 7    0      0    1    1    0
#> 8    0      0    1    1    0
#> 9    0      0    1    1    0
#> 10   0      0    1    1    0
#> 11   1      0    0    0    1
#> 12   1      0    0    0    1
#> 13   1      0    0    0    1
#> 14   1      0    0    0    1
#> 15   0      1    0    0    1
#> 16   0      1    0    0    1
#> 17   0      0    1    0    1
#> 18   0      0    1    0    1
#> 19   0      0    1    0    1
#> 20   0      0    1    0    1
# ... has 20 lines ($n$) and 5 columns ($2+3$)

toCompiled(w)
#>   Intensity Pitch Frequency
#> 1       Low  Soft         2
#> 2    Medium  Soft         3
#> 3      High  Soft         5
#> 4       Low  Hard         4
#> 5    Medium  Hard         2
#> 6      High  Hard         4
# ... has 6 lines ($2 \times 3$) and 3 columns ($f$ + 1)

toTabular(w)
#>          Pitch
#> Intensity Soft Hard
#>    Low       2    4
#>    Medium    3    2
#>    High      5    4
# ... has one table with $2 \times 3$ cells. If there had been
# more than two factors, the additional factor(s) would be on distinct layers.