1

I am using the qwraps2 package that has the summary_table function. For some reason I am getting the error "Error: x must be a formula" when I run the code below.

args(summary_table)

summary_table(death_vs_gender, summaries = qsummary(death_vs_gender))

our_summary1 <- list("Table 2: Summary Statistics for Mass 
Shooting Deaths in American between 
1966-2017 by Men & Women" = list(
                             "n" = sum(death_vs_gender$Deaths),
                             "Min" = ~ min(death_vs_gender$Deaths),
                             "Max" = ~ max(death_vs_gender$Deaths),
                             "Median" = ~ median(death_vs_gender$Deaths),
                             "Mean" = ~ mean(death_vs_gender$Deaths),
                             "Std. Dev." = ~ sd(death_vs_gender$Deaths)))


whole <- summary_table(death_vs_gender, our_summary1)
whole
Dominic Comtois
  • 10,230
  • 1
  • 39
  • 61

1 Answers1

1

There appears to be an ~ omitted from the line "n" = sum(death_vs_gender$Deaths),.

Try the following:

our_summary1 <- 
  list("Table 2: Summary Statistics for Mass Shooting Deaths in American between 1966-2017 by Men & Women" = 
       list(
            "n"         = ~ sum(Deaths),
            "Min"       = ~ min(Deaths),
            "Max"       = ~ max(Deaths),
            "Median"    = ~ median(Deaths),
            "Mean"      = ~ mean(Deaths),
            "Std. Dev." = ~ sd(Deaths)
           )
      )

Note that the name death_vs_gender has been omitted. The variables are looked for within the provided data.frame when calling summary_table. Also, starting with version 0.5.0 of qwraps2, the use of the data pronoun .data is no longer needed or recommended.

Peter
  • 7,460
  • 2
  • 47
  • 68