These functions are merely wrappers for reshape. Given the complicated syntax of reshape and the particularly simple structure of this problem, the functions facilitate the conversion enormously.

to.long(data, vars)

Arguments

data

A Meth object.

vars

The variables representing measurements by different methods. Either a character vector of names, or a numerical vector with the number of the variables in the dataframe.

Value

A data frame with the reshaped data

Details

If data represents method comparisons with exchangeable replicates within method, the transformation to wide format does not necessarily make sense.

Examples


data( milk )
str( milk )
#> 'data.frame':	90 obs. of  3 variables:
#>  $ meth: Factor w/ 2 levels "Gerber","Trig": 2 2 2 2 2 2 2 2 2 2 ...
#>  $ item: int  1 2 3 4 5 6 7 8 9 10 ...
#>  $ y   : num  0.96 1.16 0.97 1.01 1.25 1.22 1.46 1.66 1.75 1.72 ...
mw <- to.wide( milk )
str( mw )
#> 'data.frame':	45 obs. of  4 variables:
#>  $ item  : Factor w/ 45 levels "1","2","3","4",..: 1 2 3 4 5 6 7 8 9 10 ...
#>  $ repl  : Factor w/ 1 level "1": 1 1 1 1 1 1 1 1 1 1 ...
#>  $ Gerber: num  0.85 1 1 1 1.2 1.2 1.38 1.65 1.68 1.7 ...
#>  $ Trig  : num  0.96 1.16 0.97 1.01 1.25 1.22 1.46 1.66 1.75 1.72 ...
( mw <- subset( mw, as.integer(item) < 3 ) )
#>   item repl Gerber Trig
#> 1    1    1   0.85 0.96
#> 2    2    1   1.00 1.16
to.long( mw, 3:4 )
#>     meth item repl    y
#> 1 Gerber    1    1 0.85
#> 2 Gerber    2    1 1.00
#> 3   Trig    1    1 0.96
#> 4   Trig    2    1 1.16