You need to enable JavaScript to run this app. Power BI发布bupaR自定义流程映射R可视化至Web端出现兼容报错
优惠活动
大模型
产品
解决方案
定价
更多

Power BI发布bupaR自定义流程映射R可视化至Web端出现兼容报错

Power BI R脚本可视化跨端运行异常说明

基础信息

  • 脚本属性:可复现的流程地图绘制代码,需嵌入Power BI R脚本可视化模块运行
  • 运行表现差异:
    • 本地Power BI桌面端对自定义调整后的process_map对象可正常渲染,输出符合设计预期
    • 报表发布至Power BI Web门户后,触发运行错误,无法完成可视化加载
  • 环境版本核对:本地桌面端rlang包版本为rlang_0.4.10,Power BI Web端托管运行环境部署的rlang包版本为rlang_0.3.0,两端依赖包版本存在不一致。

可复现R脚本代码

# The following code to create a dataframe and remove duplicated rows is always executed and acts as a preamble for your script: 

# dataset <- data.frame(Column1)
# dataset <- unique(dataset)

# Paste or type your script code here:
library(bupaR)
library(DiagrammeR)
library(tidyverse)
library(lubridate)


# convert to proper date


processMap <- patients %>%
  process_map(sec = performance(median, "hours")
              ,type = frequency("relative_case")
              ,type_edges = frequency("absolute_case")
              ,rankdir = "LR"
              ,layout = layout_pm(edge_weight = TRUE)
              ,fixed_edge_width = F
              ,render = F
  )

# customisation(label, color, font)
processMap$nodes_df$label <- stringr::str_replace_all(processMap$nodes_df$label, c('ARTIFICIAL_START' = 'Start', 'ARTIFICIAL_END' = 'End'))
processMap$nodes_df$color <- stringr::str_replace_all(processMap$nodes_df$color, c('chartreuse4' = '#769e00', 'brown4' = '#7a0f2d'))
processMap$nodes_df$fontcolor <- stringr::str_replace_all(processMap$nodes_df$fontcolor, c('chartreuse4' = '#769e00', 'brown4' = '#7a0f2d'))
processMap$nodes_df$fontname <- stringr::str_replace_all(processMap$nodes_df$fontname, c('Arial' = 'Calibri'))
processMap$edges_df$fontname <- stringr::str_replace_all(processMap$edges_df$fontname, c('Arial' = 'Calibri'))
# change edge with
processMap$edges_df$penwidth <- scales::rescale(processMap$edges_df$penwidth, to = c(0.5, 4)) 

# custom duration edges
edges_label <- processMap$edges_df$label
tmp <- regmatches(edges_label, gregexpr("\\(.*?\\)", edges_label))
tmp <- gsub("[\\(\\)]", "", tmp)
tmp <- stringr::str_replace_all(tmp, c('character0' = '0', ' hours'=''))
tmp <- as.numeric(tmp)*60*60
tmp <- lubridate::as.duration(tmp)
tmp <- regmatches(tmp, gregexpr("\\(.*?\\)", tmp))
tmp <- gsub("[\\(\\)]", "", tmp)
edges_label_duration <- stringr::str_replace_all(tmp, c('character0' = '<1 hour'))
edges_label_count_absolute_case <- gsub("\n.*","",edges_label)
edges_label_clean <- paste0(edges_label_count_absolute_case, '\n',edges_label_duration)
 
# remove those which should have no hour()
correct_label <- gsub("\n.*","",edges_label_clean[!grepl("hour", edges_label)])
edges_label_clean[!grepl("hour", edges_label)] <- correct_label
# assign to process object
processMap$edges_df$label <- edges_label_clean

DiagrammeR::export_graph(graph = processMap, file_type = 'png', file_name = 'processMap.png')

Power BI Web端运行报错日志

Error in if (any(ind)) Encoding(x[ind]) <- "bytes" :
missing value where TRUE/FALSE needed
In addition: Warning message:
Prefixing `UQ()` with the rlang namespace is deprecated as of rlang 0.3.0.
Please use the non-prefixed form or `!!` instead.

# Bad:
rlang::expr(mean(rlang::UQ(var) * 100))

# Ok:
rlang::expr(mean(UQ(var) * 100))

# Good:
rlang::expr(mean(!!var * 100))

内容的提问来源于stack exchange,提问作者Afiq Johari

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.28 14:45:04