R Shiny VIM套件aggr

时间:2018-08-24 19:56:48

标签: r shiny

如何仅显示丢失的直方图而不显示与VIM软件包组合的图?下面的代码同时显示丢失的图和组合:-

output$miss <- renderPlot({
aggr(readDataForFreq(),col=mdc(1:2),prop =F,numbers =T,only.miss=T,plot=T,
          digits=15,
          labels = names(df), cex.axis = .9,cex.numbers=.5, oma = c(12,5,5,3),xlabs="Attributes",ylab=c("Histogram of Missing data", "Pink Missing-Blue Present"))})

谢谢

1 个答案:

答案 0 :(得分:0)

我可以使用ggplot解决此问题:-

 data <- reactive({
      var.missing<- sapply(my_func(),function(x)sum(is.na(x)))
      var.missing<- var.missing[order(var.missing)]
      missing.df<- data.frame(variable=names(var.missing),missing=var.missing,missing.prop=var.missing/dim(myfunc())[1],stringsAsFactors=FALSE)     
    })


    output$miss <- renderPlot({

      ggplot(data=as.data.frame(data()),aes(x=(factor(variable,levels=variable,ordered=FALSE)),y=missing)) +
      geom_bar(stat = "identity",position="dodge") + labs(x="Variables",y="Number of Missing Values") + 
      theme(axis.text.x=element_text(angle=45, hjust=1))


      })