R - 在闪亮的应用程序中使用 TileMaker
R - Use TileMaker in Shiny Apps
我想在我闪亮的应用程序中添加一些 TileMaker 元素,使其成为更好的仪表板(但我没有使用 shinydashboard 结构)。请参阅下面的 server.R 和 ui.R 作为最小示例:
Server.R
library(shiny)
library(TileMaker)
shinyServer(function(input, output) {
Tilemaker<-renderPlot({
Button1 <- ButtonMaker(Color = 2,Value = 3.57,Subtitle = "Times apple eaten")
Button2 <- ButtonMaker(Color = 3,Value = 13.7,Subtitle = "Nutritional value")
Button3 <- ButtonMaker(Color = 4,Value = 1,Subtitle = "Yumminess factor")
Button4 <- ButtonMaker(Color = 5,Size=1,Value = 5,Subtitle = "Inconsistencies")
Div1 <- DivMaker(Title = "Quantativity factors",Buttons = paste(Button1,Button2))
Div2 <- DivMaker(Title = "Implementation procedures",Buttons = paste(Button3,Button4))
TileMaker(MainTitle = "Hello",Divs = paste(Div1,Div2), FileName = "123.html")
browseURL("123.html")
})
})
ui.R
library(shiny)
shinyUI(fluidPage(
mainPanel(
navlistPanel(
tabPanel("Tilemaker",h1("Tilemaker"),plotOutput(Tilemaker))
)
)
)
)
我搜索了一段时间但没有相关讨论,我尝试了 renderplot 和 renderimage 但都没有用。 TilmeMaker 是另一种渲染类型还是不能在闪亮的应用程序中使用?任何建议表示赞赏。谢谢。
您需要 renderUI
(如果您想在服务器端创建 Tile)并且不需要保存(如帮助中所述
"If you would like just HTML code (suitable for inserting in a
dashboard or another document, you can use the Divs"
)
例子
library(shiny)
library(TileMaker)
server=shinyServer(function(input, output) {
output$Tilemaker<-renderUI({
Button1 <- ButtonMaker(Color = 2,Value = 3.57,Subtitle = "Times apple eaten")
Button2 <- ButtonMaker(Color = 3,Value = 13.7,Subtitle = "Nutritional value")
Button3 <- ButtonMaker(Color = 4,Value = 1,Subtitle = "Yumminess factor")
Button4 <- ButtonMaker(Color = 5,Size=1,Value = 5,Subtitle = "Inconsistencies")
Div1 <- DivMaker(Title = "Quantativity factors",Buttons = paste(Button1,Button2))
Div2 <- DivMaker(Title = "Implementation procedures",Buttons = paste(Button3,Button4))
return( list(h1("Hello"),HTML(Div1,Div2)))
})
})
ui=shinyUI(fluidPage(
mainPanel(
navlistPanel(
tabPanel("Tilemaker",h1("Tilemaker"),uiOutput("Tilemaker"))
)
)
)
)
shinyApp(ui,server)
我想在我闪亮的应用程序中添加一些 TileMaker 元素,使其成为更好的仪表板(但我没有使用 shinydashboard 结构)。请参阅下面的 server.R 和 ui.R 作为最小示例:
Server.R
library(shiny)
library(TileMaker)
shinyServer(function(input, output) {
Tilemaker<-renderPlot({
Button1 <- ButtonMaker(Color = 2,Value = 3.57,Subtitle = "Times apple eaten")
Button2 <- ButtonMaker(Color = 3,Value = 13.7,Subtitle = "Nutritional value")
Button3 <- ButtonMaker(Color = 4,Value = 1,Subtitle = "Yumminess factor")
Button4 <- ButtonMaker(Color = 5,Size=1,Value = 5,Subtitle = "Inconsistencies")
Div1 <- DivMaker(Title = "Quantativity factors",Buttons = paste(Button1,Button2))
Div2 <- DivMaker(Title = "Implementation procedures",Buttons = paste(Button3,Button4))
TileMaker(MainTitle = "Hello",Divs = paste(Div1,Div2), FileName = "123.html")
browseURL("123.html")
})
})
ui.R
library(shiny)
shinyUI(fluidPage(
mainPanel(
navlistPanel(
tabPanel("Tilemaker",h1("Tilemaker"),plotOutput(Tilemaker))
)
)
)
)
我搜索了一段时间但没有相关讨论,我尝试了 renderplot 和 renderimage 但都没有用。 TilmeMaker 是另一种渲染类型还是不能在闪亮的应用程序中使用?任何建议表示赞赏。谢谢。
您需要 renderUI
(如果您想在服务器端创建 Tile)并且不需要保存(如帮助中所述
"If you would like just HTML code (suitable for inserting in a dashboard or another document, you can use the Divs"
)
例子
library(shiny)
library(TileMaker)
server=shinyServer(function(input, output) {
output$Tilemaker<-renderUI({
Button1 <- ButtonMaker(Color = 2,Value = 3.57,Subtitle = "Times apple eaten")
Button2 <- ButtonMaker(Color = 3,Value = 13.7,Subtitle = "Nutritional value")
Button3 <- ButtonMaker(Color = 4,Value = 1,Subtitle = "Yumminess factor")
Button4 <- ButtonMaker(Color = 5,Size=1,Value = 5,Subtitle = "Inconsistencies")
Div1 <- DivMaker(Title = "Quantativity factors",Buttons = paste(Button1,Button2))
Div2 <- DivMaker(Title = "Implementation procedures",Buttons = paste(Button3,Button4))
return( list(h1("Hello"),HTML(Div1,Div2)))
})
})
ui=shinyUI(fluidPage(
mainPanel(
navlistPanel(
tabPanel("Tilemaker",h1("Tilemaker"),uiOutput("Tilemaker"))
)
)
)
)
shinyApp(ui,server)