Skip to contents

This function returns a table of descriptive statistics for numeric variables repeated over time (or otherwise repeated within subjects), with p-values calculated through repeated-measures ANOVA. The data.frame is provided in wide format.

Usage

get_desc_time(df, repeated_vars, ...)

Arguments

df

data.frame

repeated_vars

Named list of variables to be pivoted to long format

...

Additional named arguments passed to ana_fn_rm_aov()

Value

Table of descriptive statistics (output from get_desc_table())

Details

This function is a wrapper, pivoting a data.frame to long format with to_long() before calling get_desc_table() with tbl_fn=tbl_fn_num(), group="Time", ana_fn=ana_fn_rm_aov(), and id="id". Currently there is no way to change the analysis function.

Examples

v_repeated <- list(
   x=c("x1","x2","x3"),
   y=c("y1", "y2", "y3")
   )
df |> get_desc_time(v_repeated)
#>   Var    n    Mean (SD) n (Time #1) Mean (SD) (Time #1) n (Time #2)
#> 1   x 1500 -0.01 (0.81)         500        -0.01 (0.56)         500
#> 2   y 1500 -0.03 (0.83)         500         0.00 (0.61)         500
#>   Mean (SD) (Time #2) n (Time #3) Mean (SD) (Time #3)    p
#> 1        -0.01 (0.79)         500        -0.02 (1.01) .885
#> 2        -0.03 (0.80)         500        -0.06 (1.04) .218