代码之家  ›  专栏  ›  技术社区  ›  RobertF

如何从R中使用'freq'函数生成的表中排除累积比例和总比例?

  •  0
  • RobertF  · 技术社区  · 7 年前

    freq summarytools

    library(summarytools)
    data(mtcars)
    view(freq(mtcars$cyl, totals=FALSE, cumul=FALSE))
    

    st_options(freq.cumul = FALSE, freq.totals = FALSE)

    Error in st_options(freq.cumul = FALSE, freq.totals = FALSE) : 
      unused arguments (freq.cumul = FALSE, freq.totals = FALSE)
    

    cyl_freq <- freq(mtcars$cyl, report.nas = FALSE, totals=FALSE, cumul=FALSE, style = "rmarkdown", headings = FALSE);
    view(cyl_freq)
    

    multiple_freq <- lapply(mtcars[c(2,8:11)], function(x) freq(x, report.nas = FALSE, totals=FALSE, cumul=FALSE, headings = FALSE));
    view(multiple_freq)
    
    0 回复  |  直到 7 年前
        1
  •  1
  •   Matt    7 年前

    summarytools

    frtable <- table(mtcars$cyl)
    
    percent <- prop.table(frtable)
    
    dt <- cbind(frtable , percent) %>% set_colnames(c("Count", "Percent"))
    
    DT::datatable(dt) %>% DT::formatPercentage('percent')
    
    
        2
  •  1
  •   Dominic Comtois    5 年前

    lapply

    library(summarytools)
    freq(mtcars[c(2,8:11)], 
         report.nas=FALSE, totals=FALSE, cumul=FALSE, headings=FALSE)
    

    remotes::install_github("dcomtois/summarytools")

    推荐文章