Tworzę błyszczącą aplikację kątomierza z wbudowanymi rAmCharts w błyszczące funkcje. Wciąż pojawia się błąd x must be of class "numeric" instead of "character"
kiedy próbuję wprowadzić zmienną wejściową dla xwartość amAngularGauge. To jest mój główny problem. Innym bocznym problemem jest to, że chciałbym, aby tło było czarne, ale wokół miernika pojawia się biały blok, którego nie wiem, jak to naprawić. Oto mój kod
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)
Odpowiedzi:
1 dla odpowiedzi № 1Według komentarzy:
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)