Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with lineheight and line.margin #64

Open
tacospider opened this issue Feb 5, 2024 · 5 comments
Open

Issue with lineheight and line.margin #64

tacospider opened this issue Feb 5, 2024 · 5 comments

Comments

@tacospider
Copy link

Thank you for this package. I'm finding it very useful.

I'm having issues with lineheight and line.margin. They do not appear to be functional and lineheight is auto regardless of my input.

Please see below example. Please let me know if I have made an obvious error!

author_year <- c("A 2023" , "B 2020" , "C 2003")
analysis <- c("unadj" , "adj" , "adj")
int_event <- c(200 , 150 , 100)
int_total <- c(400 , 400 , 300)
cont_events <- c(50 , 150 , 100)
cont_total <- c(105 , 300 , 200)
or <- c(1.5 , 1.1 , 1.3)
lowerci <- c(1.1 , 0.7 , 0.9)
upperci <- c(2.0 , 1.9 , 1.6)

df <- data.frame(author_year , analysis , int_event , int_total , cont_events , cont_total , or , lowerci , upperci)
df

df %>%
forestplot(labeltext = c(author_year , analysis , int_event , int_total , cont_events , cont_total) ,
mean = or ,
lower = lowerci ,
upper = upperci ,
xlog = TRUE ,
lineheight = unit(0.1 , "cm")) %>%
fp_add_header(author_year = c("", "Study") ,
analysis = c("", "Analysis") ,
int_event = c("Int" , "events") ,
int_total = c("" , "total") ,
cont_events = c("Cont" , "events"),
cont_total = c("", "total")) %>%
fp_set_zebra_style("#EFEFEF")

image

@Phiido
Copy link

Phiido commented Feb 18, 2024

I'm having similar issues with lineheight, however, I am getting a "Error in unit(attr(labels, "no_rows") * attr(labels, "cex") * 1.5, "lines") : 'x' and 'units' must have length > 0", when either putting "lines" or any type of "unit(2, 'cm')" into the argument.

After some debugging, it seems when calling the forestplot function, it tries to plot the legend part and is passed on and tested inside the prFpGetLayoutVP function in which it fails as none of the attributes are passed on for the legend part.

Edit: Can also add that I'm running R 4.3.2 and forestplot 3.1.3. As well as doing group_by in my forestplot call.

gforge added a commit that referenced this issue Mar 19, 2024
@gforge
Copy link
Owner

gforge commented Mar 19, 2024

Sorry for not getting to this earlier, the line.margin seems to be causing issues in the fix. Could you check that the other lineheight works as expected?

@tacospider
Copy link
Author

No problem. Thanks for looking into it.

I re-installed the package from the CRAN, but the same problem with lineheight and line.margin remain. They do not seem to be functional and don't change the graph regardless of input. graphwidth and colgap appears to work as they should.

Thanks again.

@gforge
Copy link
Owner

gforge commented Mar 20, 2024

I haven't published it yet - you need to use devtools::install_github("gforge/forestplot", branch = "develop")

@tacospider
Copy link
Author

Great, thanks. That seems to fix the lineheight issue which was my main concern. Thank you!

FYI I think the install should ref = "develop"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants