Skip to content

Commit

Permalink
fix global variable binding
Browse files Browse the repository at this point in the history
  • Loading branch information
Manon Martin authored and Manon Martin committed Mar 19, 2024
1 parent 25426d3 commit e967f2a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
10 changes: 5 additions & 5 deletions R/lmpContributions.R
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,13 @@ lmpContributions <- function(resLmpPcaEffects, nPC = 5) {
varPercentage = unname(resLmpPcaEffects$variationPercentages)
)

plotTotal <- ggplot2::ggplot(
plotTotal <- with(dataTotal,{ggplot2::ggplot(
data = dataTotal,
ggplot2::aes(
x = stats::reorder(effects, -varPercentage),
y = varPercentage
)
) +
)}) +
ggplot2::geom_bar(stat = "identity") +
ggplot2::xlab("Effects") +
ggplot2::ylab("Percentage of Variance") +
Expand All @@ -157,7 +157,7 @@ lmpContributions <- function(resLmpPcaEffects, nPC = 5) {

dataContrib <- as.data.frame(effect_vector[seq_len(10)])

plotContrib <- ggplot2::ggplot(
plotContrib <- with(dataContrib, {ggplot2::ggplot(
data = dataContrib,
ggplot2::aes(
x = stats::reorder(
Expand All @@ -166,11 +166,11 @@ lmpContributions <- function(resLmpPcaEffects, nPC = 5) {
),
y = dataContrib[, 1]
)
) +
)}) +
ggplot2::geom_bar(stat = "identity") +
ggplot2::xlab("Contributions") +
ggplot2::ylab("Percentage of Variance") +
ggplot2::scale_x_discrete(limits = rownames(data)) +
ggplot2::scale_x_discrete(limits = rownames(dataContrib)) +
ggplot2::theme_bw()


Expand Down
4 changes: 2 additions & 2 deletions R/pcaScreePlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pcaScreePlot <- function(resPcaBySvd, nPC = 5,
res <- data.frame(var = resPcaBySvd$var[seq_len(nPC)])
res <- res %>% rownames_to_column("PC")

ggplot2::ggplot(
with(res, {ggplot2::ggplot(
data = res,
ggplot2::aes(
x = factor(PC, levels = PC),
Expand All @@ -49,5 +49,5 @@ pcaScreePlot <- function(resPcaBySvd, nPC = 5,
ggplot2::xlab("Principal Components") +
ggplot2::ylab("Percentage of Variance") +
ggplot2::ggtitle(title) +
theme
theme})
}
22 changes: 12 additions & 10 deletions R/plotLine.R
Original file line number Diff line number Diff line change
Expand Up @@ -127,31 +127,31 @@ plotLine <- function(Y, rows = 1, type = c("l", "p", "s"),

if (!is.null(color)) {
if (color == "rows") {
fig <- ggplot2::ggplot(
fig <- with(Y_long, {ggplot2::ggplot(
data = Y_long,
ggplot2::aes(
x = x_axis, y = value,
group = rownames, color = rownames
)
)
)})
color <- NULL
} else {
fig <- ggplot2::ggplot(
fig <- with(Y_long, {ggplot2::ggplot(
data = Y_long,
ggplot2::aes(
x = x_axis, y = value,
group = rownames
)
)
)})
}
} else {
fig <- ggplot2::ggplot(
fig <- with(Y_long, {ggplot2::ggplot(
data = Y_long,
ggplot2::aes(
x = x_axis, y = value,
group = rownames
)
)
)})
}


Expand Down Expand Up @@ -203,13 +203,15 @@ plotLine <- function(Y, rows = 1, type = c("l", "p", "s"),

if (type == "s") {
if (!is.null(color)) {
fig <- fig + ggplot2::geom_segment(aes(xend = x_axis, yend = 0),
fig <- with(Y_long,{fig +
ggplot2::geom_segment(aes(xend = x_axis, yend = 0),
size = size, lineend = "round", color = color
)
)})
} else {
fig <- fig + ggplot2::geom_segment(aes(xend = x_axis, yend = 0),
fig <- with(Y_long,{fig +
ggplot2::geom_segment(aes(xend = x_axis, yend = 0),
size = size, lineend = "round"
)
)})
}
}

Expand Down

0 comments on commit e967f2a

Please sign in to comment.