Skip to content

Commit b7ac06c

Browse files
committed
move tidyr to Suggests, pass local tests
1 parent 80ff86c commit b7ac06c

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

DESCRIPTION

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Imports:
4040
methods,
4141
rlang,
4242
RSpectra,
43-
tidyr
43+
survival
4444
Suggests:
4545
dplyr,
4646
gglasso,
@@ -49,7 +49,8 @@ Suggests:
4949
markdown,
5050
rmarkdown,
5151
splines,
52-
testthat (>= 3.0.0)
52+
testthat (>= 3.0.0),
53+
tidyr
5354
VignetteBuilder:
5455
knitr
5556
Config/testthat/edition: 3

R/plot.sparsegl.R

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,18 @@ plot.sparsegl <- function(x,
5656
}
5757

5858
n_legend_values <- nrow(xb)
59-
df <- as.data.frame(t(as.matrix(xb)))
60-
61-
df$lambda <- x$lambda
62-
df$penalty <- sgnorm / max(sgnorm)
63-
df <- tidyr::pivot_longer(df, !c(.data$lambda, .data$penalty), names_to = y_axis)
59+
df <- data.frame(
60+
lambda = rep(x$lambda, times = nrow(xb)),
61+
penalty = rep(sgnorm / max(sgnorm), times = nrow(xb)),
62+
value = as.vector(t(as.matrix(xb)))
63+
)
64+
df[[y_axis]] <- rep(rownames(xb), each = ncol(xb))
6465

6566
plot_layer <- ggplot2::ggplot(
6667
df, ggplot2::aes(
6768
x = !!rlang::sym(x_axis), y = .data$value, color = !!rlang::sym(y_axis)
6869
)
69-
) +
70-
ggplot2::geom_hline(yintercept = 0)
71-
70+
)
7271
if (x_axis == "penalty") {
7372
xlab_layer <- ggplot2::xlab("penalty / max (penalty)")
7473
}
@@ -91,6 +90,8 @@ plot.sparsegl <- function(x,
9190
theme_layer <- theme_layer + ggplot2::theme(legend.position = "none")
9291
}
9392

94-
p <- plot_layer + xlab_layer + legend_layer + theme_layer
93+
p <- plot_layer + xlab_layer + legend_layer + theme_layer +
94+
ggplot2::geom_hline(yintercept = 0)
95+
9596
return(p)
9697
}

0 commit comments

Comments
 (0)