I'm using the freq
function from the summarytools
package to create frequency tables in RStudio.
It doesn't seem possible to turn off the cumulative and total percentage columns in the tables. For example:
library(summarytools)
data(mtcars)
view(freq(mtcars$cyl, totals=FALSE, cumul=FALSE))
still produces a table containing duplicate cumulative and total percentage columns. All I need is a table with the variable values, count #, and percentage.
I've tried resetting the global options with st_options(freq.cumul = FALSE, freq.totals = FALSE)
but receive an error message:
Error in st_options(freq.cumul = FALSE, freq.totals = FALSE) :
unused arguments (freq.cumul = FALSE, freq.totals = FALSE)
UPDATE
Finally figured it out - I wasn't using enough arguments in the freq
function. The following code produces a decent frequency table:
cyl_freq <- freq(mtcars$cyl, report.nas = FALSE, totals=FALSE, cumul=FALSE, style = "rmarkdown", headings = FALSE);
view(cyl_freq)
and if you need to create a bunch of tables across multiple columnsmultiple_:
multiple_freq <- lapply(mtcars[c(2,8:11)], function(x) freq(x, report.nas = FALSE, totals=FALSE, cumul=FALSE, headings = FALSE));
view(multiple_freq)