R 有光泽的绘图间隙未移动

R 有光泽的绘图间隙未移动,r,shiny,R,Shiny,有人能告诉我为什么我的情节不动吗?我希望每次我改变大陆时,它都会改变,以显示不同的大陆。但是情节没有改变。。。这一年也不会改变。。。救命啊!代码如下: library(shiny) library(tidyverse) library(DT) library(stringr) library(tools) library(gapminder) # Define UI for application that plots features of movies ----------- ui &l

有人能告诉我为什么我的情节不动吗?我希望每次我改变大陆时,它都会改变,以显示不同的大陆。但是情节没有改变。。。这一年也不会改变。。。救命啊!代码如下:

library(shiny)
library(tidyverse)
library(DT)
library(stringr)
library(tools)
library(gapminder)


# Define UI for application that plots features of movies -----------
ui <- fluidPage(
    
    # Application title -----------------------------------------------
    headerPanel("Life Expectancy Over Time"),
    
    # Sidebar layout with a input and output definitions --------------
    sidebarLayout(
        
        # Inputs: Select variables to plot ------------------------------
        sidebarPanel(
            
            # Select variable for y-axis ----------------------------------
            selectInput(inputId = "y",
                        label = "Continent",
                        choices = levels(gapminder$continent),
                        selected = "Asia"),
            
            # Select variable for x-axis ----------------------------------
           
            
            # Select variable for color -----------------------------------
            
            
            # Set alpha level ---------------------------------------------
            sliderInput(inputId = "year",
                        label = "Year:",
                        min = 1952, max = 2007,
                        value = 2002)
            
        ),
        
        # Output --------------------------------------------------------
        mainPanel(
            
            # Show scatterplot --------------------------------------------
            plotOutput(outputId = "lineplot"),
            
            # Show data table ---------------------------------------------
            DT::dataTableOutput(outputId = "continent")
        )
    )
)

# Define server function required to create the scatterplot ---------
server <- function(input, output) {
    
    # Create scatterplot object the plotOutput function is expecting --
    output$lineplot <- renderPlot({
        gapminder2 <- gapminder %>% group_by(year)%>%
            filter(continent=="Africa" | continent=="Americas"|
                       continent=="Asia"| continent=="Europe"|
                   continent == "Oceania")
        ggplot(data = gapminder2, aes(x = year, y = lifeExp,
                                         color = country)) +
            geom_line() +
            labs(x = "Time",
                 y = "Life Expectancy",
                 color = "country")+ theme(legend.position = "none") 
    })
    
    # Print data table if checked -------------------------------------
    output$continent <- DT::renderDataTable({
        DT::datatable(data = gapminder[, 1:6],
                      options = list(pageLength = 10),
                      rownames = FALSE)
    })
}

# Create the Shiny app object ---------------------------------------
shinyApp(ui = ui, server = server)
库(闪亮)
图书馆(tidyverse)
图书馆(DT)
图书馆(stringr)
图书馆(工具)
图书馆(gapminder)
#为绘制电影功能的应用程序定义UI-----------

ui在哪里告诉
shinny
使用
input$y
?(您也没有使用
input$year
)要详细说明@r2evans的评论,您需要使您的绘图依赖于输入,以便在您更改输入时它会发生更改。例如,您可以在绘图中使用
过滤器(大陆==输入$y)
,这样当您选择不同大陆时,绘图将仅反映该大陆的数据。(另外,我不会引用通过
y
选择大陆的输入)。