Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R “x”和“y”长度在ioslides中一起不同,但不是单独不同_R_Shiny_Markdown_R Markdown_Ioslides - Fatal编程技术网

R “x”和“y”长度在ioslides中一起不同,但不是单独不同

R “x”和“y”长度在ioslides中一起不同,但不是单独不同,r,shiny,markdown,r-markdown,ioslides,R,Shiny,Markdown,R Markdown,Ioslides,我有两个动画iSlide,它们在单独的演示文稿中可以正常工作,但在同一演示文稿中会导致错误“x”和“y”长度不同。这是我的MWE --- title: "Untitled" runtime: shiny output: ioslides_presentation --- ##Outliers ```{r, echo = FALSE, warning=FALSE} sliderInput("multiplier", label = "Distance:", max = 1.35, min =

我有两个动画iSlide,它们在单独的演示文稿中可以正常工作,但在同一演示文稿中会导致错误“x”和“y”长度不同。这是我的MWE

---
title: "Untitled"
runtime: shiny
output: ioslides_presentation
---

##Outliers

```{r, echo = FALSE, warning=FALSE}
sliderInput("multiplier", label = "Distance:", max = 1.35, min = 1, value = 
1, ticks=FALSE, animate=
          animationOptions(interval = 100, playButton = "run"))

 x     <- seq(5,15,length=50)  
 Day1 <- rnorm(50,mean=10,sd=0.5)

renderPlot({
 Day1[22] <- max(Day1)*input$multiplier
 plot(x,Day1, ylim=c(8.5,15.5))
 text(x=14, y=14.5, labels=paste0("Mean: ", round(mean(Day1),2)))
 text(x=14, y=14, labels=paste0("Median: ", round(median(Day1),2)))
})
```

##bootstrap
```{r, warning=FALSE}
library(plyr)
sliderInput("animation", "Number of samples:", 1,1000,1, step = 1, animate=
          animationOptions(interval=30, loop=FALSE))

x=c()
for (i in 1:1000) {
 x[i] <- round(rnorm(n=200, mean=10, sd=1),1)
}
dfx <- data.frame(x)

renderPlot({
 mp <- 
barplot(count(dfx[1:input$animation,])$freq,count(dfx[1:input$animation,])$x)
   axis(1,at=mp,labels=count(dfx[1:input$animation,])$x)
  legend("topright", legend=paste0("mean: 
",round(mean(dfx[1:input$animation,]),3)), bty="n")
})  

renderUI({
 plotOutput("unsized", height = 500, width = 400)
})
```

大概是一些琐碎的东西,但是当我单独查看代码时,我找不到任何东西

我认为这与x/Day1的位置有关。我通常将其放置在renderPlot函数中,如下所示,这似乎适合我:

```{r, echo = FALSE, warning=FALSE}
inputPanel(
sliderInput("multiplier", label = "Distance:", max = 1.35, min = 1, value = 
1, ticks=FALSE, animate=animationOptions(interval = 100, playButton = "run"))
)

renderPlot({
 x <- seq(5,15,length=50)  
 Day1 <- rnorm(50,mean=10,sd=0.5)
 Day1[22] <- max(Day1)*(input$multiplier)
 plot(x,Day1, ylim=c(8.5,15.5))
 text(x=14, y=14.5, labels=paste0("Mean: ", round(mean(Day1),2)))
 text(x=14, y=14, labels=paste0("Median: ", round(median(Day1),2)))
})
```

或者,您可以先将x和Day1定义为反应值。您能否给出一个示例,说明如何首先将x和Day1定义为反应值?