Hi I am very new to using R but I am creating a forest plot for diagnostic test accuracy meta analysis using the meta package in R. I have performed a subgroup analysis and created my plot but I want to get rid of the words 'subgroup = subgroupname' and just have the subgroup name. Is this possible? The 'subgroup' is the name of this column in my dataframe. If I make it blank, R automatically calls it X, so it appears as 'X = subgroupname'. This is my code so far:
SR2 <- data.frame(Author=c('A', 'B', 'C', 'D', 'E', 'F'),
TP=c(1, 2, 3, 4, 5, 6),
FP=c(5, 6, 7, 8, 9, 10),
TN=c(9, 10, 11, 12, 13, 14),
FN=c(13, 14, 15, 16, 17, 18),
subgroup=c('q', 'r', 's', 't', 'r', 's'))
SR2_filtered <- SR2[SR2$subgroup != "Missing", ]
subgroup_sens3_filtered <- metaprop(SR2_filtered$TP, SR2_filtered$TP + SR2_filtered$FN,
byvar = SR2_filtered$subgroup,
comb.fixed = FALSE, comb.random = TRUE, sm = "PRAW",
method.ci = "CP", studlab = SR2_filtered$Author)
subgroup_spec3_filtered <- metaprop(SR2_filtered$TN, SR2_filtered$TN + SR2_filtered$FP,
byvar = SR2_filtered$subgroup,
comb.fixed = FALSE, comb.random = TRUE, sm = "PRAW",
method.ci = "CP", studlab = SR2_filtered$Author)
forest(subgroup_sens3_filtered, xlab = "Sensitivity",
col.square="cornflowerblue",
col.square.lines="navy",
col.diamond="red",
colgap.left = "18mm")
forest(subgroup_spec3_filtered, xlab = "Specificity",
col.square = "cornflowerblue",
col.square.lines = "navy",
col.diamond = "red",
colgap.left = "18mm")
snapshot of the relevant bit of my plot
I have tried various suggestions from chat gpt but no success and I'm just going round in circles as all suggestions seem to be trying to modify the text but the text comes through automatically in the forest plot.
The closest I've got is this code which removes the prefix 'subgroup =' but also removes the subgroup name which isn't what I want. The code saying print.subgroup.name = TRUE doesn't seem to do anything.
forest(subgroup_sens3_filtered,
print.subgroup.labels = FALSE,
print.subgroup.name = TRUE,
xlab = "Sensitivity",
col.square = "cornflowerblue",
col.square.lines = "navy",
col.diamond = "red",
colgap.left = "18mm")
Modify the subgroup.name
element before plotting, as follows:
subgroup_sens3_filtered$subgroup.name <- ""
forest(subgroup_sens3_filtered, xlab = "Sensitivity",
col.square="cornflowerblue",
col.square.lines="navy",
col.diamond="red",
colgap.left = "18mm")