WillemSleegers / tidystats-v0.3

R package to produce a tidy output file of statistical models.
Other
22 stars 2 forks source link

`add_stats()` first argument: model or results #64

Closed WillemSleegers closed 6 years ago

WillemSleegers commented 6 years ago

What should be the first argument for add_stats()?

Currently, the model output is the first argument. My initial reasoning for that was that it enables the user to pipe the output of an analysis directly into the tidystats list, like so:

results <- lm(extra ~ group, data = sleep) %>%
  add_stats(results, identifier = "M_sleep_lm")

results <- t.test(extra ~ group, data = sleep) %>%
  add_stats(results, identifier = "M_sleep_t_test")

However, as Ron Dotsch pointed out (https://twitter.com/RonDotsch/status/994120973623414784), why not use the results list as the first argument? That way you can first run your analyses, and later add them to your tidystats list, like so:

M_sleep_lm <- lm(extra ~ group, data = sleep)
M_sleep_t_test <- t.test(extra ~ group, data = sleep)

results <- results %>%
  add_stats(M_sleep_lm) %>%
  add_stats(M_sleep_t_test)

I think I'm favoring this latter option, for the following reasons:

arnoudplantinga commented 6 years ago

I think I also prefer the second option. Then I can just have a long pipe of add_stats calls at the end of my script, which is neater than doing it throughout your script.

WillemSleegers commented 6 years ago

I made the switch. =)