/ / R Shiny rAmCharts calibre angular x valor que no aparece como numérico - r, brillante

R El valor de x del indicador angular rAmCharts brillante no aparece como numérico - r, brillante

Estoy creando una aplicación brillante de un indicador angular con rAmCharts con características brillantes. Sigo recibiendo el error x must be of class "numeric" instead of "character" cuando intento ingresar una variable de entrada para la xvalor de amAngularGauge. Ese es mi principal problema. Otro problema secundario es que me gustaría que el fondo fuera negro, pero hay un bloque blanco alrededor del indicador que aparece y no sé cómo arreglarlo. Aquí está mi código.

library(shiny)
library(rAmCharts)
library(shinythemes)




choices = data.frame(var = c("Whiskey", "Pure Alc", "Wine", "Beer"),
num = c(40, 95, 10, 5))

lc = as.list(choices$num)

names(lc) = choices$var

ui <- fluidPage(
theme = shinytheme("cyborg"),
selectInput("drink", "Choose your drink...", choices = lc),
amChartsOutput("gauge")


)

server <- function(input, output) {

output$gauge = renderAmCharts({
amAngularGauge(input$drink,
bands = data.frame(start = c(0, 50),
end = c(50, 100),
color = c("#0000FF", "#ea3838"),
step = 20),
text = "%")
})
}

shinyApp(ui = ui, server = server)

Respuestas

1 para la respuesta № 1

Según los comentarios:

library(shiny)
library(rAmCharts)
library(shinythemes)

choices = data.frame(var = c("Whiskey", "Pure Alc", "Wine", "Beer"), num = c(40, 95, 10, 5))
lc = as.list(choices$num)
names(lc) = choices$var

ui <- fluidPage(
theme = shinytheme("cyborg"),
column(3,selectInput("drink", "Choose your drink...", choices = lc)),
column(3,br(),amChartsOutput("gauge",width = 300,height = 250))
)

server <- function(input, output) {

output$gauge = renderAmCharts({
amAngularGauge(as.numeric(input$drink),
bands = data.frame(start = c(0, 50),
end = c(50, 100),
color = c("#0000FF", "#ea3838"),
step = 20), text = "%")
})
}

shinyApp(ui = ui, server = server)

enter image description here