Skip to content

Commit a4e0e63

Browse files
author
Raphael
committed
Update plot.R
1 parent b4db99d commit a4e0e63

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

R/plot.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ plot.Distribution <- function(x, fun=c('pdf','cdf'), npoints = 3000,
7272
if(any(is.na(fun)))
7373
stop("Function unrecognised, should be one of: ", paste0(plotFuns,collapse=","))
7474

75-
if("cdf" %in% fun & !x$isCdf){
75+
if(any(c("cdf", "survival", "hazard","cumhazard") %in% fun) & !x$isCdf){
7676
message("This distribution does not have a cdf expression. Use the FunctionImputation decorator to impute a numerical cdf.")
7777
fun = fun[!(fun %in% c("cdf", "survival", "hazard","cumhazard"))]
7878
}
7979

80-
if("pdf" %in% fun & !x$isPdf){
80+
if(any(c("pdf", "hazard") %in% fun) & !x$isPdf){
8181
message("This distribution does not have a pdf expression. Use the FunctionImputation decorator to impute a numerical pdf.")
8282
fun = fun[!(fun %in% c("pdf", "hazard"))]
8383
}
@@ -114,10 +114,10 @@ plot.Distribution <- function(x, fun=c('pdf','cdf'), npoints = 3000,
114114
plotStructure <- stats::aggregate(cdf ~ points, plotStructure, max)
115115
}
116116

117-
if ("cdf" %in% fun & !("cdf" %in% colnames(plotStructure))) {
117+
if (any(c("cdf", "survival", "hazard","cumhazard") %in% fun) & !("cdf" %in% colnames(plotStructure))) {
118118
plotStructure$cdf <- x$cdf(plotStructure$points)
119119
}
120-
if ("pdf" %in% fun) {
120+
if (any(c("pdf", "hazard") %in% fun) %in% fun) {
121121
plotStructure$pdf <- x$pdf(plotStructure$points)
122122
}
123123

0 commit comments

Comments
 (0)