Open tacospider opened 9 months ago
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.
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?
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.
I haven't published it yet - you need to use devtools::install_github("gforge/forestplot", branch = "develop")
Great, thanks. That seems to fix the lineheight issue which was my main concern. Thank you!
FYI I think the install should ref = "develop"
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")