【发布时间】:2021-12-17 23:05:02
【问题描述】:
我正在尝试使用 Shiny 和 plotly 在散点图上显示误差线。这是我的 server.R 文件中的代码:
data = reactiveVal()
observe({
results <- data.frame() # actually getting the data from here
# formatting output
final.results <- cbind(
"id" = paste(results$a,
results$b,
results$c,
sep = '-'),
"sigma" = sprintf("%.5g", results$s),
"c-e" = sprintf("%.3g",results$calc - results$exp)
)
data(final.results)
})
output$plot <- renderPlotly(
as.data.frame(data()[,c("id", "c-e", "sigma")]) %>% plot_ly(
x = ~`c-e`,
y = ~id,
height = 800,
type = 'scatter',
mode = 'markers',
marker = list(color = "#90AFD9"),
error_x = list(array = ~sigma, color = "#000000", type = "data")
)
)
情节还可以,只是没有显示误差线,我的错误是什么?
编辑:澄清data() 函数的来源及其返回值。
【问题讨论】:
-
请澄清您的问题。距离关闭仅一步之遥。我投票决定暂时开放。
-
感谢您的投票。我更新了问题以澄清上下文。希望这会做到。