R 无法从被动数据对象中查看数据帧

R 无法从被动数据对象中查看数据帧,r,ggplot2,shiny,R,Ggplot2,Shiny,我正在尝试制作一个非常简单的闪亮应用程序,它可以从曝光组和对照组的在线广告中获得销售的置信区间 这是我的密码:- ui.R library(shiny) shinyUI(fluidPage( # Application title titlePanel("Easy Confidence Intervals for Proportions"), # Sidebar with input for the number of trials sidebarLayout( si

我正在尝试制作一个非常简单的闪亮应用程序,它可以从曝光组和对照组的在线广告中获得销售的置信区间

这是我的密码:-

ui.R

library(shiny)

shinyUI(fluidPage(

  # Application title
  titlePanel("Easy Confidence Intervals for Proportions"),

  # Sidebar with input for the number of trials
   sidebarLayout(

 sidebarPanel(
 numericInput("exGrpSize", "Exposed Group Impressions", 10000),
 numericInput("exGrpConv", "Exposed Group Clicks or Conversions", 100),
 numericInput("contGrpSize", "Control Group Impressions", 10000),
 numericInput("contGrpConv", "Control Group Clicks or Conversions", 100)
 ),

# Show a plot of the generated distribution
mainPanel(
  plotOutput("intervalPlot")
    )
   )
))
library(shiny)
library(ggplot2)

# Define server logic required to draw a histogram
shinyServer(function(input, output) {

  # This is some very simple code to draw confidence intervals for proportions
  # wrapped in a call to renderPlot to indicate that:
  #  1) It is "reactive" and therefore should re-execute automatically when inputs change
  #  2) Its output type is a plot

  data <- reactive({
    resp1 <- input$exGrpConv
    size1 <- input$exGrpSize
    resp2 <- input$contGrpConv
    size2 <- input$contGrpSize
    rate1 <- resp1/size1
    rate2 <- resp2/size2
    se1 <- 1.96*sqrt((1/size1)*rate1*(1-rate1))
    se2 <- 1.96*sqrt((1/size2)*rate2*(1-rate2))
    dataSet <- data.frame(
                  respVec = c(rate1, rate2),
                  group = factor(c("Exposed", "Control")),
                  se = c(se1, se2))
    })

#   # Define the top and bottom of the errorbars
   limits <- aes(ymax = respVec + se, ymin = respVec - se)
#   
  output$intervalPlot <- renderPlot({  
# 
   p <- ggplot(dataSet, aes(colour=group, y = respVec, x = group))
   p + geom_point() + geom_errorbar(limits, width=0.2, lwd=2)
})
})
server.R

library(shiny)

shinyUI(fluidPage(

  # Application title
  titlePanel("Easy Confidence Intervals for Proportions"),

  # Sidebar with input for the number of trials
   sidebarLayout(

 sidebarPanel(
 numericInput("exGrpSize", "Exposed Group Impressions", 10000),
 numericInput("exGrpConv", "Exposed Group Clicks or Conversions", 100),
 numericInput("contGrpSize", "Control Group Impressions", 10000),
 numericInput("contGrpConv", "Control Group Clicks or Conversions", 100)
 ),

# Show a plot of the generated distribution
mainPanel(
  plotOutput("intervalPlot")
    )
   )
))
library(shiny)
library(ggplot2)

# Define server logic required to draw a histogram
shinyServer(function(input, output) {

  # This is some very simple code to draw confidence intervals for proportions
  # wrapped in a call to renderPlot to indicate that:
  #  1) It is "reactive" and therefore should re-execute automatically when inputs change
  #  2) Its output type is a plot

  data <- reactive({
    resp1 <- input$exGrpConv
    size1 <- input$exGrpSize
    resp2 <- input$contGrpConv
    size2 <- input$contGrpSize
    rate1 <- resp1/size1
    rate2 <- resp2/size2
    se1 <- 1.96*sqrt((1/size1)*rate1*(1-rate1))
    se2 <- 1.96*sqrt((1/size2)*rate2*(1-rate2))
    dataSet <- data.frame(
                  respVec = c(rate1, rate2),
                  group = factor(c("Exposed", "Control")),
                  se = c(se1, se2))
    })

#   # Define the top and bottom of the errorbars
   limits <- aes(ymax = respVec + se, ymin = respVec - se)
#   
  output$intervalPlot <- renderPlot({  
# 
   p <- ggplot(dataSet, aes(colour=group, y = respVec, x = group))
   p + geom_point() + geom_errorbar(limits, width=0.2, lwd=2)
})
})
库(闪亮)
图书馆(GG2)
#定义绘制直方图所需的服务器逻辑
shinyServer(功能(输入、输出){
#这是一些非常简单的代码,用于绘制比例的置信区间
#包装在对renderPlot的调用中,以指示:
#1)它是“反应式”的,因此当输入发生变化时应自动重新执行
#2)其输出类型为绘图

data我相信您必须在响应函数的末尾返回
dataSet
,即

data <- reactive({
    resp1 <- input$exGrpConv
    size1 <- input$exGrpSize
    resp2 <- input$contGrpConv
    size2 <- input$contGrpSize
    rate1 <- resp1/size1
    rate2 <- resp2/size2
    se1 <- 1.96*sqrt((1/size1)*rate1*(1-rate1))
    se2 <- 1.96*sqrt((1/size2)*rate2*(1-rate2))
    dataSet <- data.frame(
                  respVec = c(rate1, rate2),
                  group = factor(c("Exposed", "Control")),
                  se = c(se1, se2))
    dataSet
    })

我正在努力理解这是什么类型的对象——
data()
object——以及如何访问它的列……例如,如果我想要se2,我可以使用data()访问吗$se2?这在ggplot中不是太大的问题,因为
aes
允许您自己引用列,但是
dygraphs
例如可能也需要列引用。