How to change panel labels and x-axis sublabels in a lattice bwplot

前端 未结 1 1616
借酒劲吻你
借酒劲吻你 2021-01-17 20:52

I\'m 2 weeks into using RStudio (MacOS) so please forgive me if I\'m overlooking an obvious function that would solve my problem.
As a project, I am attempting to reprod

相关标签:
1条回答
  • 2021-01-17 21:10

    The simplest way as far as I can see is to convert your tx and dztype to factors with the appropriate level names.

    tx <- factor(tx, levels=c(0,1), labels=c("Talk Therapy", "Drug Therapy"))
    dztype <- factor(dztype, levels=c(0,1), labels=c("Not severe", "Severe"))
    bwplot(NBwtp1000 ~ tx | dztype, xlab="Talk Therapy or Drug Therapy", 
           ylab="Net Benefit @ wtp 1000", horizontal=FALSE)
    

    enter image description here

    Another solution is to use argument scale for the tx levels and argument strip for dztype:

    tx <- c(0,0,0,0,1,1,1,1)
    dztype <- c(1,0,1,0,0,0,1,1)
    bwplot(NBwtp1000 ~ tx | dztype, xlab="Talk Therapy or Drug Therapy", 
           ylab="Net Benefit @ wtp 1000", horizontal=FALSE,
           scales=list(x=list(labels=c("Talk therapy","Drug Therapy"))), 
           strip=strip.custom(var.name="Disease severity", 
                              factor.levels=c(" Not Severe", "Severe"),
                              strip.levels=rep(TRUE,2)))
    

    enter image description here

    0 讨论(0)
提交回复
热议问题