outcome <- c(1, 1.2, 0.8, 0.9)
cumulative_mean <- cummean(outcome)
# Create a data frame with the cumulative means and their indices
df <- data.frame(cumulative_mean = cumulative_mean, index = 1:length(cumulative_mean))
# Plot the cumulative means
ggplot(df, aes(x = index, y = cumulative_mean)) +
geom_point() +
xlab("Index") +
ylab("Cumulative Mean") +
ggtitle("Cumulative Mean Plot")+
theme_minimal()
1条答案
按热度按时间f45qwnt81#
好的,你要找的是累积平均值:
以下是ggplot版本:
这是R基版本: