adayim / forestploter

Draw forestplot in R
Other
79 stars 10 forks source link

Issue with choosing the row numbers in forest function #52

Closed MahdokhtNaghash closed 1 year ago

MahdokhtNaghash commented 1 year ago

Hi! Thank you for this amazing package.

There was an issue I encountered when I wanted to choose the rows I wanted to visualize. When you try to change the order of the rows, choose rows that are not consecutive and or not starting from 1 you will get different types of false results. Sometimes the plot for the last row will disappear and sometimes no matter what row you put in, you will get the results for the first row of your data and sometimes everything will be just misplaced.

For what I wanted to do, there was an easy fix which was only keeping the rows I wanted to work with from the beginning. But if I wanted to change the order of the rows, I would have a problem.

Just thought maybe it was worth reporting.

`p <- forest(dt[2:7,c(1:3, 20:21)],
            est = dt$est,
            lower = dt$low, 
            upper = dt$hi,
            sizes = dt$se,
            ci_column = 4,
            ref_line = 1,
            arrow_lab = c("Placebo Better", "Treatment Better"),
            xlim = c(0, 4),
            ticks_at = c(0.5, 1, 2, 3),
            footnote = "This is the demo data. Please feel free to change\nanything you want.",
            theme = tm)`

Rplot

adayim commented 1 year ago

Hi,

It is not the problem with the package. It is the problem with the data you have provided. The plotting data you have provided is from row 2 to 7, but you have provided all the point estimation and confidence interval. Use the following instead.

dt <- dt[2:7,]
p <- forest(dt[,c(1:3, 20:21)],
            est = dt$est,
            lower = dt$low, 
            upper = dt$hi,
            sizes = dt$se,
            ci_column = 4,
            ref_line = 1,
            arrow_lab = c("Placebo Better", "Treatment Better"),
            xlim = c(0, 4),
            ticks_at = c(0.5, 1, 2, 3),
            footnote = "This is the demo data. Please feel free to change\nanything you want.",
            theme = tm)`
MahdokhtNaghash commented 1 year ago

As I said, that's how I figured the problem would go away but didn't understand why. I'm a beginner and was mistaken to think I could play around with rows the same way I did with columns. Sorry if I wasted your time then! Thanks for the explanation. I'm gonna close this issue :)