2017-12-08 4 views
0

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) 

반짝 코드는 다음과 같습니다. "유한 'ylim'값이 필요합니다"

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) 

} 

빛나는 반환 오류가 필자는 $ qtype 입력이 올바른 정보를 plot 명령에 전달하지 못한다고 생각하지만,이를 수정하는 방법을 모르겠습니다. 미리 감사드립니다.

+0

제공하신 코드는 독립 실행 형 재현 할 수있는 예가 아닙니다. 쉽게 실행할 수있는 코드를 추가하십시오. 줄거리 호출이 "aggScaled"와 "bar"를 시도하고 실패 할 것임을 알았습니다. 실패합니다. – awchisholm

답변

1

방금 ​​문제를 해결했습니다. 서버 누락 된 코드는 다음과 같습니다

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

그리고이) (규모 음모 않는 선택 플롯을 보여줍니다.

관련 문제