下面的代码是针对一个平淡的altman情节,y-作为&data;' datax'的差异。和'数据'并且在x-作为&data;' datax'的平均值。和'数据'。但我想在y上绘制差异作为百分比,如下所示:(datax-datay)/ mean * 100,包含所有下限和上限。有人可以帮我处理代码吗?
b1.stat <- bland.altman.stats(datax, datay)
b1.stat.data <- data.frame(means=b1.stat$means, diffs=b1.stat$diffs)
ggplot(data=b1.stat.data, aes(x=means, y=diffs)) +
geom_point() +
geom_hline(yintercept=b1.stat$CI.lines[["lower.limit.ci.lower"]]) +
geom_hline(yintercept=b1.stat$CI.lines[["lower.limit.ci.upper"]]) +
geom_hline(yintercept=b1.stat$CI.lines[["upper.limit.ci.lower"]]) +
geom_hline(yintercept=b1.stat$CI.lines[["upper.limit.ci.upper"]]) +
geom_hline(yintercept=b1.stat$CI.lines[["mean.diff.ci.lower"]], colour=
'red', linetype = "dashed") +
geom_hline(yintercept=b1.stat$CI.lines[["mean.diff.ci.upper"]], colour=
'red', linetype = "dashed") +
geom_hline(yintercept=b1.stat$lines[["lower.limit"]], linetype=2) +
geom_hline(yintercept=b1.stat$lines[["upper.limit"]], linetype=2) +
geom_hline(yintercept=b1.stat$lines[["mean.diffs"]], colour= 'red') +
geom_hline(yintercept=0)
答案 0 :(得分:0)
创建自己的百分比值向量
b1.stat <- bland.altman.stats(datax, datay)
# Difference vector
differences <- datax - datay
# Differences as percentages
diff.as.perentages <- (differences / b1.stat$means) * 100
b1.stat.data <- data.frame(means = b1.stat$means, diffs = diff.as.perentages)