我设法找到了一些R代码,使用一组数据样本进行绘图,并为Mandell Kandell Analysis提供正确的P和Tau值。工作良好。不确定我是否安装了正确的软件包以发出我想要的东西。
在线研究
library(ggplot2)
library(dplyr)
library(zoo)
library(Kendall)
#End of first set of commands
#Begin second set of commands
data1 <- ts(c(33,35,34,35,22,24,26,30,20,26,33,18), start=c(2018, 1), end=c(2018, 12), frequency=12)
mk.test(data1)
data1X <- c(1:length(data1))
data1Fit <- lm(data1~data1X)
data1df <- data.frame(date=as.Date(time(data1)), Y=as.matrix(data1))
ggplot(data=data1df, mapping=aes(x=date, y=Y, ymin = 0))+geom_point() +
geom_line(color='blue') +
stat_smooth(method = "lm", col = "red") +
xlab("Months") +
ylab("Complaints") +
scale_x_date(date_breaks = "1 month", date_labels = '%b %y') +
labs(title = paste("Adj R2 = ",signif(summary(data1Fit)$adj.r.squared, 5),
" Slope =",signif(data1Fit$coef[[2]], 5)))````
the ability to change the geoM_point to Bar. I want to see bars in the plot as opposed to points.