1

I am using R 4.0 in Windows 10 and the manipulate sliders don't appear to be working with any of the examples that I take from the videos or textbook.

I did not meet any errors while running the code below, everything works perfectly except for not seeing the slider.

Is anyone else experiencing the same issue?

library(manipulate)
library(ggplot2)
library(HistData)
myHist <- function(mu){
  g <- ggplot(Galton, aes(x = child))
  g <- g + geom_histogram(fill = "salmon", 
                          binwidth=1, aes(y = ..density..), colour = "black")
  g <- g + geom_density(size = 2)
  g <- g + geom_vline(xintercept = mu, size = 2)
  mse <- round(mean((Galton$child - mu)^2), 3)  
  g <- g + labs(title = paste('mu = ', mu, ' MSE = ', mse))
  g
}
manipulate(myHist(mu), mu = slider(62, 74, step = 0.5))
Marco Sandri
  • 23,289
  • 7
  • 54
  • 58
yliu3089
  • 11
  • 1
  • 1
    There is no base or ggplot2 function called `slider`. What packages are you using, other than ggplot2? Do you have some reproducible data that you can share? – Phil Jul 19 '20 at 16:09
  • It seems like a bug. Try first running the command `manipulate(plot(1:5, cex=size), size = slider(0.5,10,step=0.5))` and then your code. It works. – Marco Sandri Jul 19 '20 at 19:21
  • 1
    @MarcoSandri It works! Interesting.... Thank you! – yliu3089 Jul 19 '20 at 20:26

1 Answers1

0

Running the following first:

manipulate(plot(1:5, cex=size), size = slider(0.5,10,step=0.5))

As suggested in this comment by Marco Sandri resolved the problem for me.

dbc
  • 104,963
  • 20
  • 228
  • 340