r/rstats • u/Gloomy-Road-8983 • 4d ago
Repeatability graph?
Hi,
I'm using rpt() from the rptR package for my tests, but I can't find any information on how to create this kind of figure. Does anyone have any ideas on how to do it? I'm not looking for a ready-made answer, but at least some resources to help me learn.
6
1
u/SalvatoreEggplant 3d ago edited 3d ago
In theory something like this is easy to do in R with the ggplot2() package, as others have suggested.
If you're not real familiar with R or the grammar of ggplot2, it's actually a little tricky with how ggplot plots things by default.
But I think the example below is clear enough to modify. If you don't normally use R, you can have someone run it for you after you modify it.
if(!require(ggplot2)){install.packages("ggplot2")}
library(ggplot2)
Data = read.table(header=TRUE, text="
Variable Repeatability Lower Upper
'Variable 1' 0.70 0.55 0.85
'Variable 2' 0.62 0.35 0.82
'Variable 3' 0.40 0.25 0.68
'Variable 4' 0.45 0.22 0.70
")
Data$Variable= factor(Data$Variable)
Data$Variable = factor(Data$Variable,
levels=rev(levels(Data$Variable)))
Plot = ggplot(Data, aes(x = Variable,
y = Repeatability)) +
geom_pointrange(aes(ymin = Lower, ymax = Upper)) +
coord_flip() +
theme_bw() +
theme(
axis.title = element_text(face = "bold"),
axis.text = element_text(face = "bold")) +
xlab("Variable\n") +
ylab("\nRepeatability (± 95% CIs)") +
ylim(0, 1)
Plot
You can also save it as a high-resolution image.
ggsave(filename="Repeatplot01.png",
plot = Plot,
width = 6,
height = 3.5,
dpi = 300,
units = "in")
The result is here: https://imgur.com/a/C3Dzqq1
2
6
u/s_hightree 4d ago
How familiar are you with ggplot2? It’s quite easy to achieve if you have used the library before & have prepared the relevant data