0

I am trying to calculate group means from a 4-way mixed ANOVA. The code is working great -- and I can output the results into my console -- but how do I save this table to a file (i.e. export as a .csv)? I tried using the capture.output() command, but then it cannot find the object score.

##Group Means    
data %>%
  group_by(region, task, production, position) %>%
  get_summary_stats(score, type = "mean_sd")
Ben Bolker
  • 211,554
  • 25
  • 370
  • 453

1 Answers1

0

I think you're looking for readr::write_csv() (or write.csv() from base R)

library(dplyr)
library(readr)
library(readr)
mtcars %>% 
    group_by(cyl) %>% 
    get_summary_stats(hp, type="mean_sd") %>% 
    write_csv("my_output.csv")

You might also be interested in the emmeans package, for getting "expected marginal means" from more complex statistical models.

Ben Bolker
  • 211,554
  • 25
  • 370
  • 453