【问题标题】:Building basic plot R Shiny data from CSV从 CSV 构建基本绘图 R Shiny 数据
【发布时间】:2017-04-04 18:27:04
【问题描述】:

Ok 我是 R 新手,但这不应该这么难我试图在 Shiny 中运行一个非常基本的散点图,就像我在 R Studio 中基于一些 CSV 数据所做的那样。当我运行 Shiny 应用程序时,我得到了图表的空白区域。当我在 R studio 中运行该图时,它工作得很好。如果有人有理想请告诉我

library(shiny)
library(shinydashboard)
library(plyr)
# Simple header -----------------------------------------------------------
header <- dashboardHeader(title="Basic")

sidebar <- dashboardSidebar()

body <- dashboardBody(
  fluidPage(
    fluidRow(
      box(plotOutput("Scores", height = 250)),
    )
  )
)

ui <- dashboardPage(header, sidebar, body, skin="black")

# Setup Shiny app back-end components -------------------------------------

server <- function(input, output) { 

  output$scatteredplot <- renderPlot ({
    data <- read.csv("Scores.csv")
    averageTime<-ddply(data, .(IP, OS), summarize, time=mean(time), score=mean(score), status=mean(status))
    plot(averageTime$RemediationTime,averageTime$score,xlab="time", ylab="score")
  })


  }

# Render Shiny app --------------------------------------------------------

shinyApp(ui, server)

【问题讨论】:

    标签: r shiny shinydashboard


    【解决方案1】:

    错误在于下面两行的组合

    box(plotOutput("Scores", height = 250)),
    

    你在这里寻找一个叫做分数的情节,但是

    output$scatteredplot <- renderPlot ({
    

    你只定义了一个叫做散点图的图

    所以将最后一行替换为

    output$Scores <- renderPlot ({
    

    其实

    里面还有一个多余的逗号
     box(plotOutput("Scores", height = 250)),  
    

    但这可能是为了生成一个最小的可重现示例

    【讨论】:

    • 为什么?你不应该;)
    • 我有一个正在使用的示例模板,甚至没有注意到赋值运算符。是的,非常感谢你
    猜你喜欢
    • 2020-07-23
    • 1970-01-01
    • 2014-10-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多