简体   繁体   English

散点图显示 Shiny 中.Rdata 的关联

[英]Scatterplot showing association of .Rdata in Shiny

I am a complete beginner with programming and R, and currently I'm trying to learn how to make a Shiny app.我是一个编程和 R 的完整初学者,目前我正在尝试学习如何制作 Shiny 应用程序。 Also, I am sorry if I'm repeating the question that was already asked, I wasn't able to find solution to my problem.另外,很抱歉,如果我重复已经提出的问题,我无法找到解决问题的方法。 So I have made a "data.Rdata" list from which I'm using the variables.所以我制作了一个“data.Rdata”列表,从中使用变量。 My x is numVars and y is catVars.我的 x 是 numVars,y 是 catVars。 So i have managed to do everithyng except show the association of selected numerical and categorical variable with a scatterplot.因此,除了显示所选数值和分类变量与散点图的关联外,我已经设法做到了一切。 For that purpose I found a code which I don't know how to integrate with my.Rdata dataset because I am not able to find function to load 1. Rdata in it and 2. how to input my numerical and categorical variable on x and y axis.为此,我找到了一个我不知道如何与 my.Rdata 数据集集成的代码,因为我无法找到 function 来加载 1. Rdata 和 2. 如何在 x 和y 轴。 The code that i found was using mtcars dataset and I don't know how to replace it so it can work properly with the dataset that I have.我发现的代码正在使用 mtcars 数据集,我不知道如何替换它,以便它可以与我拥有的数据集一起正常工作。 For sure there is a more elegant solution for simulating this I'm just not able to find it.当然有一个更优雅的解决方案来模拟这个我只是找不到它。 Any help would be great, thank you.任何帮助都会很棒,谢谢。

  selected <- reactiveVal(rep(FALSE, nrow(mtcars)))
   
   observeEvent(input$plot_brush, {
     brushed <- brushedPoints(mtcars, input$plot_brush, allRows = TRUE)$selected_
     selected(brushed | selected())
   })
   observeEvent(input$plot_reset, {
     selected(rep(FALSE, nrow(mtcars)))
   })
   
   output$plot <- renderPlot({
     mtcars$sel <- selected()
     ggplot(mtcars, aes(wt, mpg)) + 
       geom_point(aes(colour = sel)) +
       scale_colour_discrete(limits = c("TRUE", "FALSE"))
   }, res = 96)
   
   output$summary<-renderPrint({      
     summary(d("data.Rdata"))
   })
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM