r - 如何在闪亮 (R) 中绘制流程图 (bupar)?
问题描述
在我的应用程序中,我想上传一个本地 csv 文件(事件日志),显示数据表,然后使用 csv 文件(bupar)中的数据创建一个流程图。在普通的 R 脚本中,进程图的创建工作正常。但是,如何通过按下按钮“createDiagram”按钮在闪亮的应用程序中绘制流程图(在 DataTables 下方)?提前致谢!
代码下方:
library(shiny)
ui <- fluidPage(
titlePanel("Visualization"),
sidebarLayout(
sidebarPanel(
fileInput("file1", "Choose a File:",
multiple = FALSE,
accept = c("text/csv",
"text/comma-separated-values,text/plain",
".csv")),
tags$hr(),
actionButton("createDiagram","Create a Process Diagram"),
tags$hr()
),
mainPanel(
tableOutput("contents"),
plotOutput("plot")
)
)
)
server <- function(input, output) {
output$contents <- renderTable({
req(input$file1)
tryCatch(
{
inputData <- read.csv2(input$file1$datapath)
},
error = function(e) {
stop(safeError(e))
}
)
})
}
# Create Shiny app ----
shinyApp(ui, server)
解决方案
processmap() 输出一个 dgr_graph 对象。这些可以在闪亮的应用程序中呈现
library(DiagrammeR)
grVizOutput(outputId = "process")
和
output$process <- renderGrViz({
plot <- process_map(eventlog, render = F)
render_graph(plot)
})
推荐阅读
- python - 如何解决matplotlib?安装错误?
- css - 浏览器有时会使用错误的字体来渲染图标,导致文字乱码
- c++ - DirectX 数学中 XMMatrixDecompose() 的对面?
- laravel - Laravel:将模型/行从一个连接复制到另一个
- python-3.x - Pillow 将 png 转换为 8bit 位图
- ios - 数字协议的通用扩展
- javascript - 无法在文件阅读器 Javascript 中访问文件名
- r - How to duplicate data based on matches in two different columns
- bash - 如果使用 += 连接,如何在 bash 脚本中附加换行符?
- python - 单个位置索引器越界使用检查数据框第二列的函数过滤列表