score:0

Accepted answer

i found the answer here in case it is useful to anyone.

just need to use the function ensym from library rlang. so in my code jus changed the hcaes line to this:

hcaes(x = !!rlang::ensym(x), y = !!rlang::ensym(y), group = !!rlang::ensym(group))

score:1

this is a common issue: hcaes is based on ggplot2::aes and acts similarly, luckily, you can access it as a string, ggplot2 has aes_string and highcharter has hcaes_string

library(shiny)
library(highcharter)

gral  <- function(df,x,y,group,theme){
    highchart() %>%
        hc_xaxis(type = "category") %>%
        hc_add_series(df, "line",
                      hcaes_string(x = x, y = y, group = group),
                      datalabels = list(enabled = true,
                                        style = list(fontsize = '13px'))) %>% 
        hc_legend(enabled = true) %>% 
        hc_tooltip(shared = true, crosshairs = true,style = list(fontsize = "18px")) %>%
        hc_add_theme(theme) 
}

ui <- basicpage(
    column(12,
           highchartoutput('usuariosgral')
    )
)

server <- function(input, output, session) {
    
    output$usuariosgral <- renderhighchart({  
        gral(df = mtcars,x ='mpg',y = 'disp',group ='cyl',theme = hc_theme_elementary())
    })
    
}

shinyapp(ui, server)

enter image description here


Related Query

More Query from same tag