【问题标题】:Error: (list) object cannot be coerced to type 'logical' adding legend错误:(列表)对象不能被强制输入“逻辑”添加图例
【发布时间】:2013-04-08 09:10:56
【问题描述】:

我在使用 R 中的 legend 时遇到问题。我正在处理生存数据,我有两条卡普兰梅尔曲线。我需要识别我的情节中的每一个。我正在使用图例,这是我尝试过的:

plot(kmenfprimaria.dos.inicio, ylab="2B. Probabilidad de supervivencia", 
     family="Times Roman", xlab="Tiempo en días", 
     sub="Mediana: LLA 175 IC 95% (142-295); LMA: 159 IC 95% (59-NR). p(log-rank)=0.783",
     ps=3, cex.main=0.9, cex.sub=0.7, cex.lab=0.7, 
     main="Supervivencia por diagnóstico", cex.main=0.9, lty=c(1,2), lwd=2, 
     legend(450, 0.8,legend= c("LLA","LMA"), lty=c(1,2), lwd=2))

错误:(列表)对象不能被强制输入“逻辑”

我不知道如何强制对象。

【问题讨论】:

    标签: r legend


    【解决方案1】:

    legend 不是plot 的参数,您需要调用plot() 然后legend() 例如

    plot(kmenfprimaria.dos.inicio, ylab="2B. Probabilidad de supervivencia", 
     family="Times Roman", xlab="Tiempo en días", 
     sub="Mediana: LLA 175 IC 95% (142-295); LMA: 159 IC 95% (59-NR). p(log-rank)=0.783",
     ps=3, cex.main=0.9, cex.sub=0.7, cex.lab=0.7, 
     main="Supervivencia por diagnóstico", cex.main=0.9, lty=c(1,2), lwd=2)
    
     legend(450, 0.8,legend= c("LLA","LMA"), lty=c(1,2), lwd=2)
    

    【讨论】:

      猜你喜欢
      • 2016-09-12
      • 2021-03-01
      • 1970-01-01
      • 2016-05-22
      • 1970-01-01
      • 2016-09-30
      • 2020-11-30
      • 2016-05-24
      • 1970-01-01
      相关资源
      最近更新 更多