【问题标题】:R Shiny- Contingency TablesR Shiny- 列联表
【发布时间】:2017-03-17 09:17:04
【问题描述】:

我无法在 Shiny 中创建列联表。它导致两列并排而不是交叉表。

output$currtarget<-renderTable({

    currtgt<- cstable %>%

      select(parent_id,tutor_id,status_name,first_name) #%>%

      xtabs(as.formula(paste0("~",status_name,"+",first_name),currtgt)

  })

【问题讨论】:

    标签: shiny contingency


    【解决方案1】:

    这也发生在我身上,今天更新了我所有的包之后——上周它运行良好。不知道为什么会改变,但它非常很烦人!

    无论如何,我的解决方法是使用as.data.frame.matrix,然后在大括号和最后一个括号之间设置include.rownames=TRUE

    renderTable = ({
    ...
    my_tbl = addmargins(table(one_group, another_group))
    printed_tbl = as.data.frame.matrix(my_tbl)
    print_tbl
    }, include.rownames=TRUE)
    

    【讨论】:

      猜你喜欢
      • 2022-01-20
      • 2022-01-20
      • 1970-01-01
      • 1970-01-01
      • 2021-01-23
      • 1970-01-01
      • 2021-02-11
      • 2014-07-01
      • 1970-01-01
      相关资源
      最近更新 更多