Search code examples
rcomparegroups

CompareGroups package in R


I have a dataset with 100 columns and 4 groups.

I want to apply compareGroups function to have descriptive and inferential statistics for my data.

However; compareGroups function is taking a formula as follows: compareGroups(Grouping variable~variable1+variable2..and so on). what would be the code to use compareGroups for the whole 100 columns without specifying name of each and every column in my dataset?

Thanks in advance


Solution

  • Try:

    compareGroups(Grouping variable ~ ., data = dataframe)

    The . refers to all other ("explanatory") variables.

    Please note that compareGroups performs a univariate analysis with the dataframe between group (“response” variable) and all other variables (“explanatory” variables).

    For more information see the compareGroups vignette.