0

I have an excel table with the data of the Odds Ratios of different diseases for my study. I want to make a forestplot with the R package ggplot2. I have used this script:

library(ggplot2)

df <- excel.xlsx

fp <- ggplot(data=df, aes(x=Disease, y=OR, ymin=Lower, ymax=Upper)) +
geom_pointrange() + 
geom_hline(yintercept=1, lty=2) +  # add a dotted line at x=1 after flip
coord_flip() +  # flip coordinates (puts labels on y axis)
xlab("Disease") + ylab("OR (95% CI)") +
theme_bw()  # use a white background
print(fp)

This makes round black spots for all diseases.I would like to change the shape of the dots on the graph to squares or other different form, but only to some diseases. I would like to change the shape of the points on the graph corresponding to rows 6, 8, 14 and 16 and the rest of the points leave them as they are now. Thank you in advanced.

I have tried this script but it makes only black spots.

Phil
  • 7,287
  • 3
  • 36
  • 66
Pablo
  • 1
  • 1
    Your example is currently not [reproducible](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). You can provide your data using `dput(df)` or `dput(head(df))` if your dataframe is large. What makes rows 6, 8, 14, and 16 unique? – jrcalabrese Nov 17 '22 at 15:22
  • It is beacuse they are values from different population – Pablo Nov 21 '22 at 08:48

1 Answers1

0

the example code is not reproducible when I'm writing this answer, but I think you just need to specify shape in the aes This question includes a complete example with multiple shapes

Vida
  • 400
  • 2
  • 9