echarts4rBox函数似乎无法识别“x”变量

wtzytmuj  于 5个月前  发布在  Echarts
关注(0)|答案(1)|浏览(48)

我试过这个:

library(shiny)
library(echarts4r)

ui <- fluidPage(
  
  fluidRow(
    column(3, echarts4rBoxOutput("box1"))
  )
  
)

server <- function(input, output, session) {
  
  output$box1 <- renderEcharts4rBox({
    echarts4rBox(cars, speed, dist, "Cake", type = "bar")
  })
  
}

shinyApp(ui, server)

字符串
但是:
错误:未找到对象“speed”
我正在使用最新版本的echarts4r,但不工作。

oalqel3c

oalqel3c1#

通过向echarts4rBox函数调用提供字符串x和y列来运行代码:

library(shiny)
library(echarts4r)

ui <- fluidPage(
    
    fluidRow(
        column(3, echarts4rBoxOutput("box1"))
    )
    
)

server <- function(input, output, session) {
    
    output$box1 <- renderEcharts4rBox({
        echarts4rBox(cars, "speed", "dist", "Cake", type = "bar")
    })
    
}

shinyApp(ui, server)

字符串
问题来自于无效的输入传输和转换到内部.build_data2函数。echarts4rBox函数被设计为接受x和y输入的字符串或引号,但它不适用于引号。

> echarts4rBox
function(
  data,
  x,
  y,
  text = "",
  subtext = "",
  type = c("bar", "line", "scatter", "area", "step"),
  ...,
  color = "#ffffff",
  text_color = "#ffffff",
  background_color = "#293c55",
  step = c("start", "middle", "end"),
  title_args = list(),
  tooltip = list(trigger = "axis")
) {

  # for area, keep to use in series opts
  original_type <- type

  # inputs
  type <- match.arg(type)
  step <- match.arg(step)

  # override area
  if (type %in% c("area", "step")) type <- "line"

  # build expected data format
  data <- .build_data2(data, {{ x }}, {{ y }})
  ...

相关问题