簡體   English   中英

無法將Sparklyr連接到閃亮

[英]Can't connect sparklyr to shiny

我對Shiny和Spark很陌生。

我想部署一個帶有Spark連接的ShinyApp。 當我按下RunApp時,一切正常,但是每當我嘗試發布RunApp時,都會出現錯誤:“ value [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)

如果其他人也遇到同樣的問題,請使用以下解決方案: https : //github.com/rstudio/sparklyr/issues/1100#issuecomment-342313877

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM