我对Shiny和Spark很新。
我想部署一个带有spark连接的ShinyApp。当我刚刚点击RunApp时,一切都运行起来,但每当我尝试发布它时,我都会收到错误:“值[3L]出错: 找不到SPARK_HOME目录'/ usr / lib / spark' 电话:本地... tryCatch - > tryCatchList - > tryCatchOne - > 执行暂停“
这个目录存在于我的集群中,所以我不确定为什么它找不到它。 这是我试图发布的代码。
library(sparklyr)
library(shiny)
library(ggplot2)
library(rmarkdown)
Sys.setenv(SPARK_HOME = '/usr/lib/spark')
config<- spark_config()
spark_install(version = "2.2.0")
sc<-spark_connect(master = 'yarn-client', version = '2.2.0')
tbl_cache(sc, 'output_final_v2')
output_tbl2<-tbl(sc, 'output_final_v2')
ui <- fluidPage(
textInput("name", "Enter Name", "company"),
textInput("item_name", "Enter Item Name"),
selectInput("month", "Choose Month", choice=
c("January","February","March", "April", "May", "June", "July",
"August", "September", "October", "November", "December")),
selectInput("dow","Choose Day of Week", choice = c("Monday", "Tuesday",
"Wednesday", "Thursday", "Friday", "Saturday", "Sunday")),
numericInput("count_customers", "Enter Number of Customers:", 2),
numericInput("views", "Enter Number of Views:", 30),
plotOutput("plot1"),
plotOutput("plot2"),
plotOutput("plot3")
)
server <- function(input, output, session) {
C2<-reactive( output_tbl2 %>%
mutate(views = input$views)%>%
filter(input$name == shortname)%>%
filter(input$dow== dow)%>%
filter (input$month == month)%>%
filter (input$item_name == item)%>%
filter (input$count_customers == count_customers)%>%
collect)
output$plot1 <- renderPlot({
p1<-ggplot2::ggplot(data = C2() , aes(x=price_per_customer, y=final_probability)) + geom_line() + ggtitle("Probability of Purchase") + labs(y="Probability",x= "Item Price")
print(p1)
})
output$plot2 <- renderPlot({
p2<-ggplot2::ggplot(data=C2(), aes(x=price_per_customer, y=((views*final_probability)*price_per_customer))) + geom_line() + geom_hline(aes(yintercept = max((views*final_probability)*price_per_customer))) + ggtitle("Projected Revenue") + labs(y="Expected Revenue",x="Item Price")
print(p2)
})
output$plot3<-renderPlot({
p3<-ggplot2::ggplot(data=C2(), aes(x=price_per_customer))+ geom_line(aes(y=(views*final_probability)*price_per_customer)) + geom_line(aes(y= (((views*final_probability)/price_per_customer)))) + ggtitle("Iso-Profit vs Expected Volume")
print(p3)
})
}
shinyApp(ui, server)
答案 0 :(得分:0)
如果其他人也遇到同样的问题,请点击以下解答:https://github.com/rstudio/sparklyr/issues/1100#issuecomment-342313877