我正在制作一个有角度规的闪亮应用程序,其中rAmCharts内置闪亮功能。我一直收到错误x must be of class 'numeric' instead of 'character'
当我尝试输入amAngularGauge的x值的输入变量时。这是我的主要问题。另一个问题是,我希望背景是黑色的,但是在测量仪周围出现了一个白色的块,我不知道如何修复。这是我的代码
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)
答案 0 :(得分:1)
根据评论:
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)