You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While the bars show up in the correct order (largest to smallest), their labels are incorrect any time x is not in alphabetical order. Could this be fixed?
# first set alphabetized, second not, but with same value order
sorted <- data.frame(label = c("A", "B", "C", "D"), value = c(20, 15, 10, 5))
not_sorted <- data.frame(label = c("One", "Two", "Three", "Four"), value = c(20, 15, 10, 5))
# this one labels bars correctly
ggplot(sorted, aes(x = label, y = value)) +
ggQC::stat_pareto(point.color = "red",
point.size = 2,
line.color = "black",
bars.fill = c("coral", "yellow"))
# this one does not label bars correctly
ggplot(not_sorted, aes(x = label, y = value)) +
ggQC::stat_pareto(point.color = "red",
point.size = 2,
line.color = "black",
bars.fill = c("coral", "yellow"))
The text was updated successfully, but these errors were encountered:
It can be solved by new_df <- df |> arrange(desc(cost)) |> mutate(x=fct_reorder(x,desc(y)).
I love ggQC package and use it recently. I found the same issue and the most convinent way is just prepare the input data frame by arrange + fct_reorder.
set.seed(0)
df <- data.frame(
x = c('a', 'd', 'c', 'H1', 'Y1',
'B', 'AAA', 'Xy', '2A', '12'),
y = as.integer(runif(
n = 10, min = 0, max = 100
))
)
print(str(df |> arrange(desc(y))))
when x= Xy',y = 94, which is biggest.
Bug code from the Render Pareto Plot from ggQC onine help -------------
which put H1 in the 1st place incorrectly.
ggplot(df, aes(x = x, y = y)) +
stat_pareto(
point.color = "red",
point.size = 3,
line.color = "black",
#size.line = 1,
bars.fill = c("blue", "orange")
)
Fixed cost from Render Pareto Plot from ggQC onine help ---------------
arrange y value by desc, and mutate the x by fct_recorder
which put Xy in the 1st place incorrectly.
new_df <- df |>
arrange(desc(y)) |>
mutate(x = fct_reorder(x, desc(y)))
ggplot(new_df, aes(x = x, y = y)) +
stat_pareto(
point.color = "red",
point.size = 3,
line.color = "black",
#size.line = 1,
bars.fill = c("blue", "orange")
)
`
if you love the answer, pls vote it. thanks
While the bars show up in the correct order (largest to smallest), their labels are incorrect any time
x
is not in alphabetical order. Could this be fixed?The text was updated successfully, but these errors were encountered: