以下代码在本地具有令人满意的结果但是当上传到shinyapps.io时不起作用.
---
title: "shiny slidy app"
author: "IMI"
date: "11/29/2018"
output:
slidy_presentation:
self_contained: yes
runtime: shiny
---
```{r data, echo=FALSE, message=FALSE, warning=FALSE, paged.print=FALSE}
library(shiny)
data<- data.frame(Year= 1990:1999)
```
## First
```{r slideselect, echo=T, message=FALSE, warning=FALSE, paged.print=FALSE}
sliderInput("year", "Year",
min = min(data$Year), max = max(data$Year),
value = c(min(data$Year),max(data$Year)))
```
```{r print, echo=T}
year<-reactive(input$year)
output$rendtext<-renderText( year()[1]:year()[2])
textOutput("rendtext")
```
本地:
有什么建议吗?
最佳答案 我只是尝试了你的代码并且效果很好:
我在Rstudio中做了以下步骤:
1)创建一个新的Rmd文件
---
title: "shiny slidy app"
author: "IMI"
date: "11/29/2018"
output:
html_document:
df_print: paged
slidy_presentation:
self_contained: yes
runtime: shiny
---
```{r data, echo=FALSE, message=FALSE, warning=FALSE, paged.print=FALSE}
library(shiny)
data<- data.frame(Year= 1990:1999)
```
## First
```{r slideselect, echo=T, message=FALSE, warning=FALSE, paged.print=FALSE}
sliderInput("year", "Year",
min = min(data$Year), max = max(data$Year),
value = c(min(data$Year),max(data$Year)))
```
```{r print, echo=T}
year<-reactive(input$year)
output$rendtext<-renderText( year()[1]:year()[2])
textOutput("rendtext")
```
2)通过专用按钮在shinyapp.io上发布
此外,我尝试了一个基本的闪亮部署(看了shiny guidelines),这也没关系:它运行本地和shinyapp.io.
# Global variables can go here
library(shiny)
data <- data.frame(Year= 1990:1999)
# Define the UI
ui <- bootstrapPage(
# Input: Simple integer interval ----
sliderInput("year", "Year", min = min(data$Year), max = max(data$Year), value = c(min(data$Year),max(data$Year))),
# Output: Text output summarizing the values ----
textOutput("rendtext")
)
# Define the server code
server <- function(input, output) {
# Reactive expression for the input values ---
year <- reactive(input$year)
# Show the values ----
output$rendtext<-renderText( year()[1]:year()[2])
}
# Return a Shiny app object
shinyApp(ui = ui, server = server)