การวางแผนเชิงโต้ตอบที่แวววาวพร้อมมาตราส่วน likert ที่เลือก

ฉันได้สร้าง likert scales หลายอันด้วยแพ็คเกจ R "likert" และต้องการพล็อตแต่ละอันให้เป็นมันเงาเมื่อเลือกปุ่มตัวเลือกของอันนั้น เครื่องชั่งตัวอย่างคือ:

a <- sample(rep((1:5),5))
b <- sample(rep((1:5),5))
c <- data.frame(sapply(data.frame(a), factor))
d <- data.frame(sapply(data.frame(b), factor))
scaledc <- likert(c)
scaledd <- likert(d)

รหัสแวววาวคือ:

ui <- fluidPage(
  titlePanel("Survey"),
  sidebarLayout(
    sidebarPanel(
      selectInput("type",
                  "Plot Type",
                  choices = c("Likert"="bar",
                              "Density"="density",
                              "Heatmap"="heat"), selected="Likert"),
      radioButtons("qtype", 
                    "Question type:",
                    c("Agreement"="scaledc", "Helpfulness"="scaledd"),
                selected="scaledc")
  ),


# Show a plot of the generated distribution
mainPanel(
  tabsetPanel(
    tabPanel("Yearly Data", plotOutput("distPlot1"))
      )
    )
  )
)



#server
server <- function(input, output) {  
  output$distPlot1 <- renderPlot({plot(input$qtype, type=input$type)+
      ggtitle("How agree are you with following statements?")}, height = 1000)

}

ข้อผิดพลาดที่ส่งคืนเป็นเงา "ต้องการค่า 'ylim' ที่จำกัด" ฉันคิดว่าเป็นเพราะ input$qtype ไม่ส่งข้อมูลที่ถูกต้องไปยังคำสั่ง plot แต่ฉันไม่รู้วิธีแก้ไข ขอบคุณสำหรับล่วงหน้า!


person dorayin    schedule 08.12.2017    source แหล่งที่มา
comment
รหัสที่คุณระบุไม่ใช่ตัวอย่างที่สามารถทำซ้ำได้แบบสแตนด์อโลน โปรดเพิ่มโค้ดให้เพียงพอเพื่อให้รันได้ง่าย ฉันสังเกตเห็นว่าการเรียกใช้พล็อตจะพยายามพล็อต aggScaled และแถบซึ่งจะล้มเหลว   -  person Andrew Chisholm    schedule 08.12.2017


คำตอบ (1)


ฉันเพิ่งแก้ไขปัญหา รหัสที่หายไปในเซิร์ฟเวอร์คือ:

  scale <- reactive({
   get(input$qtype)
})
  output$dat <- renderPrint({
   scale()
})

จากนั้นทำการพล็อตด้วย scale() เพื่อแสดงพล็อตที่เลือก

person dorayin    schedule 08.12.2017