I am trying to make a forest effect size chart from several studies decorated with their type (X or Y). The dataset includes rows representing summary statistics for type X studies and type Y studies indicated by study=="Summary".
study <- as.factor(c("A","B","C","A","B","Summary","Summary"))
mean <- c(1.29,0.76,2.43,1.68,1.22,1.7,0.76)
lowerCI <- c(0.84,0.50,1.58,1.1,0.8,1.11,0.50)
upperCI <- c(1.95,1.16,3.67,2.54,1.85,2.56,1.16)
type <- as.factor(c("X","X","X","Y","Y","X","Y"))
df <- data.frame(study, mean, lowerCI, upperCI, type)
df$study <- as.factor(df$study)
I want to offset axis label labels for the total size of the effect. For some reason, using an expression ifelsedoes not work when I am a subset. In this code example, only the summary label for type X is highlighted, while both should be in bold. In my real, more complex code, no pivot tag is shown in bold.
library(ggplot2)
plot <- ggplot(data=df, aes(y=study, x=mean, xmin=lowerCI, xmax=upperCI, shape = type)) +
geom_point(color = 'black', size=2)+
geom_errorbarh(height=.1)+
geom_point(data=subset(df,study=='Summary'), color='black', size=5)+
facet_grid(type~., scales= 'free', space='free')+
theme(axis.text.y= element_text(face=ifelse(levels(df$study)=="Summary","bold","plain")))
print(plot)
, scales='free', , scales='free_x', . , , , ( , C), .
?