r语言 - 滑块不显示,因为我使用操作功能



我在Windows 10中使用R 4.0,操纵滑块似乎无法使用我从视频或教科书中获得的任何示例。

在运行下面的代码时,我没有遇到任何错误,除了看不到滑块之外,一切都很完美。

其他人也遇到同样的问题吗?

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))

首先运行以下程序:

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

正如Marco Sandri在这篇评论中所建议的那样,为我解决了问题

相关内容

最新更新