From 04fad4e61676cc20c725f518ff802dda111b4d81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lie=20Siberchicot?= Date: Wed, 14 Feb 2024 15:55:45 +0100 Subject: [PATCH] Improve the use of the 'sapply' function for graphics (outputs are hidden) --- R/plotdistcens.R | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/R/plotdistcens.R b/R/plotdistcens.R index f1d29f4c..e4e96754 100644 --- a/R/plotdistcens.R +++ b/R/plotdistcens.R @@ -260,7 +260,6 @@ plotdistcens <- function(censdata, distr, para, leftNA = -Inf, rightNA = Inf, NP nnoricens<-length(noricens$left) n<-length(censdata$left) - if (specifytitle) { plot(c(0,0),c(0,0),type="n",xlim=xlim,ylim=ylim,xlab="Censored data", ylab="CDF",main=titleCDF, ...) @@ -275,7 +274,8 @@ plotdistcens <- function(censdata, distr, para, leftNA = -Inf, rightNA = Inf, NP lines(c(xmininf, lcens[ordlcens[i]]), c(y, y), ...) } if (nlcens>=1) - toto<-sapply(1:nlcens,plotlcens) + invisible(sapply(1:nlcens,plotlcens)) + plotnoricens<-function(i) { y<-(i+nlcens)/n if (noricens[ordmid[i],]$left!=noricens[ordmid[i],]$right) @@ -284,13 +284,14 @@ plotdistcens <- function(censdata, distr, para, leftNA = -Inf, rightNA = Inf, NP points(noricens[ordmid[i],]$left,y,pch=4, ...) } if (nnoricens>=1) - toto<-sapply(1:nnoricens,plotnoricens) + invisible(sapply(1:nnoricens,plotnoricens)) + plotrcens<-function(i) { y<-(i+nlcens+nnoricens)/n lines(c(rcens[ordrcens[i]],xmaxinf),c(y,y), ...) } if (nrcens>=1) - toto <- sapply(1:nrcens,plotrcens) + invisible(sapply(1:nrcens,plotrcens)) } # en of else if NPMLE if (!missing(distr)){ # plot of the theoretical cumulative function