The below snippet is not working when I use the manipulate()
function. Only the chart appears for initial value of the slider but the control does not appear. I use a plot()
function, the control appears.
library(UsingR)
data(galton)
myHist <- function(mu){
mse <- mean((galton$child - mu)^2)
g <- ggplot(galton, aes(x = child)) + geom_histogram(fill = "salmon", colour = "black", binwidth=1) +
geom_vline(xintercept = mu, size = 3) +
ggtitle(paste("mu = ", mu, ", MSE = ", round(mse, 2), sep = ""))
g
}
manipulate(myHist(mu), mu = slider(62, 74, step = 0.5))