當我運行代碼時,出現錯誤:
? error target quantities_plot_base
? end pipeline [3.558 seconds]
Error:
! Error running targets::tar_make()
Target errors: targets::tar_meta(fields = error, complete_only = TRUE)
Tips: https://books.ropensci.org/targets/debugging.html
Last error: <text>:1:2: unexpected '/'
1: /
^
目標是串列中的以下代碼:
tar_target(
name = quantities_plot_base,
command = powerscale_seq_summ_plot(sensitivity_sequence_base)
)
而函式檔案中的powerscale_seq_summ_plot是這樣的:
powerscale_seq_summ_plot <- function(powerscale_seq) {
powerscale_plot_quantities(powerscale_seq, variables = "b_wrist", quantities = c("mean", "sd"), mcse = TRUE)
ggplot2::facet_wrap(
. ~ quantity,
scales = "free",
ncol = 3,
labeller = ggplot2::as_labeller(
c(
"b_wrist" = "",
"sd" = "SD",
"mean" = "Mean",
"cjs_dist" = "$\\text{CJS}_{\\text{dist}}$"
)
)
)
guides(colour = "none")
xlab("Power-scaling $\\alpha$")
scale_color_manual(values = rep("black", 3))
scale_shape_manual(values = c("prior" = 15, "likelihood" = 22), labels = c("Prior power-scaling", "Likelihood power-scaling"), name = NULL)
scale_linetype_manual(values = "dashed", labels = "$\\pm2$ MCSE", name = NULL)
cowplot::theme_half_open()
theme(
legend.position = "bottom",
legend.text = element_text(size = 10),
axis.text = element_text(size = 10),
axis.title = element_text(size = 10),
strip.text = element_text(size = 10),
strip.background = element_blank(),
legend.text.align = 0,
axis.line.y = element_blank(),
axis.ticks.y = element_line(colour = "black"),
axis.line.x = element_blank(),
axis.ticks.x = element_line(colour = "black"),
legend.title = element_text(size = 10),
aspect.ratio = 1
)
cowplot::panel_border(color = "black", size = 1)
}

使用您的函式(與b_wrist交換為mu; 我讓變數呼叫函式中的另一個引數)。
powerscale_seq_summ_plot(pss, "mu")
# Scale for colour is already present.
# Adding another scale for colour, which will replace the existing scale.
# Scale for shape is already present.
# Adding another scale for shape, which will replace the existing scale.
# Scale for linetype is already present.
# Adding another scale for linetype, which will replace the existing scale.

我不知道有任何庫可以讓您使用可以理解的$封裝運算式。ggplot2如果這些對你有用,那就試試吧!否則,這里有一些解決我在上圖中看到的標簽錯誤的方法。
因為"cjs_dist" = "$\\text{CJS}_{\\text{dist}}$"我不知道你想在這里做什么。你只是想顯示“CJS_dist”而不是“cjs_dist”嗎?如果是這樣,那么就是字面意思:"cjs_dist" = "CJS_dist".
供xlab("Power-scaling $\\alpha$") 使用xlab(expression(Power-scaling~alpha))
用“±2 MCSE ”scale_linetype_manual(values = "dashed", labels = "$\\pm2$ MCSE", name = NULL) 替換標簽
當我在您的 UDF(用戶定義函式)中進行這些更改時,這就是我呈現的內容。

轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/533312.html
