group_vars中的错误:缺少参数“ x”,没有默认值

时间:2019-06-05 06:36:39

标签: r shiny shinydashboard

尝试使用在闪亮的图形上创建甜甜圈图。我只是想得到一个错误: “ group_vars中的错误:缺少参数“ x”,没有默认值”

不知道怎么了? 我想使用滑块操纵甜甜圈图。我可以看到滑块,但是看不到甜甜圈图。

数据-这种模式将一直重复到2017年。我想找到一种测量的总价值:美国人和亚洲人通过甜甜圈图,并使用“年”滑块进行操作。

STATE    YEAR    measure    value

CA       2005    AMERICAN   50000
NY       2005    AMERICAN   50000

CA       2005    ASIAN      50000
NY       2005    ASIAN      50000   

复制的数据

6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L), .Label = c("ENROLL", 
"GRADES_ALL_AM", "GRADES_ALL_AS", "GRADES_ALL_BL", "GRADES_ALL_HI", 
"GRADES_ALL_WH"), class = "factor"), value = c(727716L, 121156L, 
676297L, 311432L, 5129788L, 539538L, 471918L, 104355L, 80937L, 
1980569L, 893557L, 177448L, 231632L, 1856841L, 958052L, 493957L, 
451469L, 489281L, 795719L, 211511L, 751850L, 862495L, 1600650L, 
781566L, 329408L, 834636L, 158875L, 281354L, 222846L, 177722L, 
653488L, 281407L, 2663637L, 1112636L, 118793L, 1834239L, 312817L, 
509814L, 1719829L, 138939L, 631613L, 107050L, 844668L, 3535333L, 
462323L, 97454L, 1032842L, 896197L, 317719L, 829085L, 100313L, 
730004L, 123868L, 708482L, 312695L, 4120498L, 549570L, 479522L, 
103782L, 80678L, 2039884L, 1235304L, 181212L, 236774L, 1875956L, 
963071L0L, 0L, 0L, 66L, 0L, 0L, 0L, 0L, 
0L, 0L, 13272L, 31832L, 515L, 26L, 0L, 0L, 0L, 0L, 0L, 0L, 58L, 
503L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L)), class = "data.frame", row.names = c(NA, 
-8171L))

global.r

require(plotly)
require(dplyr)

dataframe_read <- read.csv("newT1.csv")

dataframe_read1 <- dataframe_read[, (names(dataframe_read) %in% c("STATE", "YEAR", "measure", "value"))]

server.r

require(shiny)
require(shinydashboard)

shinyServer(function(input, output) {
   yearinput <- reactive({
    dataframe_read1%>%
      filter(YEAR == input$years)})


output$plot = renderPlotly(
r <- dataframe_read1 %>%
  group_by(measure) %>%
  summarize(count = n()) %>%
  plot_ly(labels = ~measure, values = ~count()) %>%
  add_pie(hole = 0.6) %>%
  layout(title = "Donut charts using Plotly",  showlegend = F,
         xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
         yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))

)
})

ui.r

library(shiny)
library(shinydashboard)

shinyUI(dashboardPage(
  dashboardHeader(title = "Working on it"),
      dashboardSidebar(
    sliderInput(
      "years",
      "Select Year:",
      min = min(dataframe_read1$YEAR),
      max = max(dataframe_read1$YEAR),
      value =  max(dataframe_read1$YEAR),
      step = 1
    )
  ),
  dashboardBody(# Boxes need to be put in a row (or column)
    fluidRow(
      box(plotlyOutput("plot"), width = 15, height = 400)
    )
  )   
  )
)

0 个答案:

没有答案