[英]Can't connect sparklyr to shiny
I'm pretty new to Shiny and Spark. 我对Shiny和Spark很陌生。
I want to deploy a ShinyApp with a spark connection. 我想部署一个带有Spark连接的ShinyApp。 Everything works how it should when I just hit RunApp, but whenever I try to publish it, I get the error: "Error in value[3L] : SPARK_HOME directory '/usr/lib/spark' not found Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> Execution halted" 当我按下RunApp时,一切正常,但是每当我尝试发布RunApp时,都会出现错误:“ value [3L]错误:找不到SPARK_HOME目录'/ usr / lib / spark'调用:本地... tryCatch-> tryCatchList-> tryCatchOne->执行暂停”
This directory exists on my cluster, so I'm not sure why it's not finding it. 该目录位于我的群集上,因此我不确定为什么找不到它。 Here's the code I'm trying to publish. 这是我要发布的代码。
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)
如果其他人也遇到同样的问题,请使用以下解决方案: https : //github.com/rstudio/sparklyr/issues/1100#issuecomment-342313877
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.