ฉันได้สร้าง 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 แต่ฉันไม่รู้วิธีแก้ไข ขอบคุณสำหรับล่วงหน้า!