내 작은 반짝이는 앱이 내 ggplot을 표시하지 못하게하는 이유는 무엇입니까? renderPlot()의 코드를 기본 플롯 기능을 사용하는 예제로 바꾸면 함께 나타납니다. 저는 Windows Vista에서 RStudio, R v3.0.1을 사용하여 Chrome 브라우저에 출력하고 있습니다.반짝이는 예상대로 내 ggplot을 표시하지 않습니다.
ui.r
library(ggplot2)
cities <- c("Anchorage","Fairbanks","Juenau","Wasilla","Homer")
years <- 2003:2013
Table <- "Capital Assets"
Account <- c("Land", "Art", "Buildings", "Equipment")
dat <- data.frame(City = sort(rep(cities, length(years))), Year = rep(years,length(cities)), Table)
sampleDat <- rbind(data.frame(dat,Acount = Account[1]), data.frame(dat, Acount = Account[2]), data.frame(dat, Acount = Account[3]), data.frame(dat, Acount = Account[4]))
finalDat <- data.frame(sampleDat, Value = runif(length(sampleDat[,1]), 1000,10000))
shinyUI(pageWithSidebar(
headerPanel("CAFR Explorer"),
selectInput("city","City", as.list(levels(finalDat$City)), selected = NULL, multiple = FALSE),
mainPanel(
h3(textOutput("caption")),
plotOutput("CAFRplot")
)))
server.r 것은
library(shiny)
library(ggplot2)
cities <- c("Anchorage","Fairbanks","Juenau","Wasilla","Homer")
years <- 2003:2013
Table <- "Capital Assets"
Account <- c("Land", "Art", "Buildings", "Equipment")
dat <- data.frame(City = sort(rep(cities, length(years))), Year = rep(years,length(cities)), Table)
sampleDat <- rbind(data.frame(dat,Acount = Account[1]), data.frame(dat, Acount = Account[2]), data.frame(dat, Acount = Account[3]), data.frame(dat, Acount = Account[4]))
finalDat <- data.frame(sampleDat, Value = runif(length(sampleDat[,1]), 1000,10000))
shinyServer(function(input, output) {
formulaText <- reactive({
paste(input$city)
})
output$caption <- renderText({
formulaText()
})
output$CAFRplot <- renderPlot({
## this one isn't working.
ggplot(finalDat, aes(x = finalDat[which(finalDat$City == input$city),2],
y = finalDat[which(finalDat$City == input$city),5])) +
geom_point()
## this one is working
#plot(finalDat[which(finalDat$City == input$city),2], y = finalDat[which(finalDat$City == input$city),5])
})
})
당신이'print' 즉'인쇄 (ggplot (...) + geom_point)에 전화 ggplot 포장하려고 인수를 구성 여기를 유용'당신은을 –
표시해야합니다 오류 메시지 대신 "작동하지 않습니다."라고 말하면됩니다. Jake는 ggplot 호출에서 인쇄물을 감싸는 것이 옳다.하지만 ggplot 호출에 다른 문제가 있다고 생각한다 (범위 지정 문제). – GSee