Skip to content

Commit

Permalink
gather replaced by pivot_longer()
Browse files Browse the repository at this point in the history
  • Loading branch information
kassambara committed Oct 29, 2024
1 parent eb7f42d commit c7ff628
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions R/ggcoxdiagnostics.R
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,20 @@ ggcoxdiagnostics <- function (fit,
else col_names <- names(stats::coef(fit))
colnames(res) <- col_names
res$xval <- xval
data2plot <- tidyr::gather(res,
key = "covariate", value = "res",
col_names)
data2plot <- tidyr::pivot_longer(
data = res, cols = dplyr::all_of(col_names),
names_to = "covariate", values_to = "res"
)

gplot <- ggplot(aes(xval, res), data = data2plot) +
geom_point(col = point.col, shape = point.shape,
size = point.size, alpha = point.alpha)

if (hline) gplot <- gplot + geom_hline(yintercept=hline.yintercept, col = hline.col,
size = hline.size, lty = hline.lty, alpha = hline.alpha)
linewidth = hline.size, lty = hline.lty, alpha = hline.alpha)

if (sline) gplot <- gplot + geom_smooth(col = sline.col, se = sline.se, method = "loess",
size = sline.size, lty = sline.lty, alpha = sline.alpha)
linewidth = sline.size, lty = sline.lty, alpha = sline.alpha)

gplot <- gplot + labs(x = xlabel, y = ylabel, title = title, subtitle = subtitle, caption = caption) + ggtheme
# customization
Expand Down

0 comments on commit c7ff628

Please sign in to comment.