添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

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 1: Unable to apply different parameters to elements using a list of parameter within

"fpTxtGp(label = gpar( cex = List of values for individual elements goes here ) )

Can you please specify any instructions in the package's pdf file?

Issue 2: Error using "font" of "fontface" within gpar in fpTxtGp. Get the error "Error in validGP(list(...)) :
must specify only one of 'font' and 'fontface' "
The error message is saying that I tried inputting both "font" and "fontface" into gpar, however I only used one of either "font" or "fontface", and get the error message using either one.

Here is an example using the code from the online Introduction to Forest Plots.

  • In the first example figure online, let's say I want the 1st label line ('Auckland') to have a smaller font size (cex = 0.5), but only this line. (Since the 1st line in the figure is a summary, the first label line is the line beginning with 'Auckland".) I would try:
  • forestplot(tabletext, 
               cochrane_from_rmeta,new_page = TRUE,
               is.summary=c(TRUE,TRUE,rep(FALSE,8),TRUE),
               clip=c(0.1,2.5), 
               xlog=TRUE, 
               col=fpColors(box="royalblue",line="darkblue", summary="royalblue"), 
               txt_gp = fpTxtGp( label  = gpar (cex = list(0.5, 1, 1, 1, 1, 1, 1) ) ) )

    I also tried c(0.5, 1, 1, 1, 1, 1, 1) in place of list(0.5, 1, 1, 1, 1, 1, 1) , but neither worked (all rows still show a cex = 1 ). Is this not the correct syntax?

  • In addition to the issue above, there seems to be a specific issue with font/fontface in gpar. For example, if I amend the above code to:
  • forestplot(tabletext, 
               cochrane_from_rmeta,new_page = TRUE,
               is.summary=c(TRUE,TRUE,rep(FALSE,8),TRUE),
               clip=c(0.1,2.5), 
               xlog=TRUE, 
               col=fpColors(box="royalblue",line="darkblue", summary="royalblue", 
               txt_gp = fpTxtGp(label = gpar (font = "bold")) )

    I would get an error reading:
    Error in validGP(list(...)) :
    must specify only one of 'font' and 'fontface'

    This error occurs if I try using either "font" or "fontface", occurs whether I use integers or characters to specify the font (e.g., 2 versus "bold"), and occurs no matter which text element I try (e.g., label vs xlab). I think there may be an issue with gpar, since I am only typing in one of either "font" or "fontface", not both, so this error does not seem correct.

    Thank you

    You must provide a list of gpars:

    forestplot(tabletext,
               cochrane_from_rmeta,new_page = TRUE,
               is.summary=c(TRUE,TRUE,rep(FALSE,8),TRUE),
               clip=c(0.1,2.5),
               xlog=TRUE,
               col=fpColors(box="royalblue",line="darkblue", summary="royalblue"),
               txt_gp = fpTxtGp(label = lapply(c(0.5, 3, 1, 1, 1, 1, 2), 
                                               function(val)  gpar(cex = val))) )

    Feel free to add a clarification suggestion to the manual. Otherwise I'll close this issue in a few days.

    Thank you, could you please clarify the
    function(val) gpar(cex = val) ? I am not getting any changes with this.

    Also, were you able to replicate the error when using "font" or "fontface" in fpTxtGp? i.e.,

    forestplot(tabletext, 
               cochrane_from_rmeta,new_page = TRUE,
               is.summary=c(TRUE,TRUE,rep(FALSE,8),TRUE),
               clip=c(0.1,2.5), 
               xlog=TRUE, 
               col=fpColors(box="royalblue",line="darkblue", summary="royalblue"), 
               txt_gp = fpTxtGp(label = gpar (font = "bold")) )

    This gives an error:

    Error in validGP(list(...)) :
    must specify only one of 'font' and 'fontface'

    The function simply takes the values in the array and creates a list of custom gpar calls. In my code the second column is much bigger than other columns - if you are still having issues then send a complete example with the actual data points that you're using.

    It seems that you should use fontface instead of font. They are the same and you simply end up with a conflict.

    Hello,
    I realized the reason I've been unable to use the list of gpar calls correctly is because I am trying to customize different rows, not columns. I see in the cran pdf that you specified this, however my attempts have been unsuccessful in formatting the list correctly so that different rows in the forest plot are different sizes, fonts, etc.
    Would you mind providing an example with code you posted on Aug 8th, but in this case making the different rows different sizes instead of making the different columns different sizes?

    Thank you!

    Sorry for the response time. I'm currently busy with other projects that have a higher priority.

    If you want to highlight a row set that row to be a summary. I believe the argument complexity will be too large with the ability to specify row-style beyond the already existing summary option and I don't think that I've implemented it (although it was a while ago I wrote the code so anything is possible). In that case I suggest that you try to write your own grid-bases forestplot, also try Stack Overflow when you need faster help than I can offer.

    I debugged this a little and the bug is caused through the font argument being numeric, see below code:

    gpar(font = "bold")
    $font
    [1] NA

    The same thing with fontface returns:

    > gpar (fontface = "bold")
    $fontface
    [1] "bold"
    $font
    

    This is caused through grid:::validGp:

        if (!is.na(match("font", names(gpars)))) {
            if (is.null(gpars$font)) 
                gpars$font <- NULL
            else {
                check.length("font")
                gpars$font <- as.integer(gpars$font)