gforge / forestplot

Advanced forest plots in R using grid graphics
40 stars 15 forks source link

Error in unit(rep(1, sum(widthcolumn)) #65

Open GreatGodMother opened 3 weeks ago

GreatGodMother commented 3 weeks ago

I run the same code and the same file as I did one year ago. However, the forestplot() function worked in the previous version, but an error occurred this year:


forest_plot <- forestplot(labeltext= as.matrix(UPF[,c(1:3)]),
                          mean=UPF[,4],
                          lower=UPF[,5],
                          upper=UPF[,6],
                          zero=1,
                          boxsize=0.5,
                          graph.pos=3,
                          hrzl_lines=list('1'=gpar(lty=1,lwd=2),
                                          '2'=gpar(lty=2),
                                          '44'=gpar(lwd=2,lty=1)),
                          graphwidth=unit(0.2,'npc'),
                          xticks=c(0.5,1,1.5,2,2.5,3),
                          is.summary=c(T,
                                       T,F,F,
                                       T,F,F,
                                       T,F,F,
                                       T,F,F,
                                       T,F,F,
                                       T,F,F,
                                       T,F,F,
                                       T,F,F,
                                       T,F,F,
                                       T,F,F,
                                       T,F,F,
                                       T,F,F,
                                       T,F,F,
                                       T,F,F
                          ),
                          txt_gp=fpTxtGp(label = gpar(cex=1),
                                         ticks = gpar(cex=1.1),
                                         xlab = gpar(cex=1),
                                         title = gpar(cex=2)),
                          lwd.zero=1.5,
                          lwd.ci=2,
                          lwd.xaxis=1,
                          xlab='Odds Ratio (95% CI)',
                          xlog=F,
                          lty.ci=1,
                          ci.vertices=T,
                          ci.vertices.height=0.2,
                          clip=c(0.1,0.1),
                          lineheight="auto",
                          line.margin=unit(5,'cm'),
                          colgap=unit(1,'cm'),
                          col=fpColors(zero = '#4D4D4D',
                                       box = 'purple',
                                       lines = '#3F494D',
                                       summary = 'purple'),
                          vertice=T,
                          fn.ci_norm='fpDrawCircleCI') ```

> Error in unit(rep(1, sum(widthcolumn)), "grobwidth", labels[[1]][widthcolumn]) : 
  'x' and 'units' must have length > 0
gforge commented 3 weeks ago

Can you provide a small code example that I can reproduce? I'm short on time so I don't have the ability to do a full debug.

GreatGodMother commented 3 weeks ago

Can you provide a small code example that I can reproduce? I'm short on time so I don't have the ability to do a full debug.

Hi,

Thanks for your reply! Here is the simplified code:


forest_plot <- forestplot(labeltext= as.matrix(UPF[,c(1:3)]),
                          mean=UPF[,4],
                          lower=UPF[,5],
                          upper=UPF[,6],
                          zero=1,
                          graph.pos=3,
                          hrzl_lines=list('1'=gpar(lty=1,lwd=2),
                                          '2'=gpar(lty=2),
                                          '44'=gpar(lwd=2,lty=1)),
                          xticks=c(0.5,1,1.5,2,2.5,3),
                          lwd.xaxis=1,
                          xlog=F,
                          lty.ci=1,
                          clip=c(0.1,0.1),
                          fn.ci_norm='fpDrawCircleCI')
gforge commented 3 weeks ago

Ideally I would like to have a sample of the UPF