发布到Shinyapps.io,ERROR无法更改工作目录

时间:2016-05-23 21:34:21

标签: r shiny-server shiny

我的代码如下:

library(shiny)
library(ggplot2)
library(xlsx)
library(rsconnect)

setwd("C:/Users/John/Documents/golfersTools/golferAPP")
golfstats <- read.csv("golfers_app.csv", header = TRUE)


ui <- fluidPage(


  titlePanel("Golfers and their tools"),
  sidebarLayout(
    sidebarPanel(


      selectInput("golfstatInput", " Golf Stat Choice",
                              choices = c("drivers", "irons", "putter", "balls"), 
                             selected = "irons" )),
    mainPanel( plotOutput("plotOutput"),
               br(), br(),
               tableOutput("results")
  )
)
)

server <- function(input, output) {

  golfstats <- read.csv("golfers_app.csv", header = TRUE)
  .e <- environment()
  environment = environment()

    output$plotOutput <- renderPlot({


      if (input$golfstatInput == "irons"){

        i <- ggplot(golfstats, aes(x= reorder(golfstats$PLAYER.NAME, -golfstats$X.GIR),
                               y= golfstats$X.GIR, fill=golfstats$Irons), envrionment = .e ) + geom_bar(stat = "identity") + 
          xlab("Player") + ylab("GIR %") + coord_cartesian(ylim=c(50,75)) +
          ggtitle("Brand of Irons for highest GIR %") + scale_fill_discrete(name = "Iron Brand") + theme(axis.text.x = element_text(angle = 45, hjust = 1))
    print(i) 

      }


      if (input$golfstatInput == "drivers"){


        d <- ggplot(golfstats, aes(x= reorder(golfstats$PLAYER.NAME, -golfstats$AVG.),
                                 y= golfstats$AVG., fill=golfstats$Type.of.Driver), environment = .e ) + geom_bar(stat = "identity") +
          xlab("Player") + ylab("Average Drive distance") + coord_cartesian(ylim=c(250,320)) +
          ggtitle("Brand of Driver for PGA golfers with longest Avg Drive") + scale_fill_discrete(name = "Driver Brand") + theme(axis.text.x = element_text(angle = 45, hjust = 1))
        print(d)

      }

      if (input$golfstatInput == "putter"){


        d <- ggplot(golfstats, aes(x= reorder(golfstats$PLAYER.NAME, golfstats$Avg.Putts),
                                 y= golfstats$Avg.Putts, fill=golfstats$PutterUsed), environment = .e ) + geom_bar(stat = "identity") +
          xlab("Player") + ylab("Average Number of Putts") + coord_cartesian(ylim=c(1,2)) +
          ggtitle("Brand of Putter for PGA golfers with lowest Avg Putts") + scale_fill_discrete(name = "Putter Brand") + theme(axis.text.x = element_text(angle = 45, hjust = 1))
        print(d)

      }


      if (input$golfstatInput == "balls"){


        d <- ggplot(golfstats, aes(x= reorder(golfstats$PLAYER.NAME, golfstats$ave.score),
                                   y= golfstats$ave.score, fill=golfstats$ball.used), environment = .e ) + geom_bar(stat = "identity") +
          xlab("Player") + ylab("Average Score") + coord_cartesian(ylim=c(50,80)) +
          ggtitle("Brand of Ball for PGA golfers with lowest Avg Score") + scale_fill_discrete(name = "Ball Brand") + theme(axis.text.x = element_text(angle = 45, hjust = 1))
        print(d)

      }

    })
}
shinyApp(ui = ui, server = server)      

我一直收到错误,无法从shinyapps.io更改工作目录。我有一种感觉,我的问题与发布到服务器的本地数据有关。我尝试以管理员身份运行RStudio进行发布。我看了整个谷歌,还没有找到类似的问题(附带解决方案)有没有人有任何想法?

0 个答案:

没有答案