0

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

1 Answers1

0

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.

Captain Hat
  • 2,444
  • 1
  • 14
  • 31
  • Can one define a group on the fly? For instance if there are 35 group variables but you want to reduce it to binary. For example, does this work, `compareGroups(groupvariable == "ASRI" ~., data = dataframe)` – Farrel Nov 15 '22 at 04:01