Giter Club home page Giter Club logo

Comments (3)

Wang-Yong2018 avatar Wang-Yong2018 commented on August 25, 2024 1

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.

Below is the full cost to demo purpose:

`library(ggQC)
library(ggplot2)
library(forcats)
library(tidyverse)

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")
)
`

from ggqc.

factorialmap avatar factorialmap commented on August 25, 2024 1

It works! thank you so much for that !

library(tidyverse)
library(ggQC)

df <- tibble(type_nc = c("scratch","spots","folds","holes","rips"),
             qty = c(201,78,47,31,15),
             cost = c(4287,2423,1119,8947,1864))

df %>% 
  arrange(desc(cost)) %>% 
  mutate(type_nc = fct_reorder(type_nc, desc(cost))) %>% 
  ggplot(aes(x = type_nc, 
             y = cost))+
  stat_pareto(point.color = "darkgray",
              point.size = 2,
              line.color = "darkgray",
              bars.fill = c("gray","lightblue"))

from ggqc.

Wang-Yong2018 avatar Wang-Yong2018 commented on August 25, 2024

glad to know that. I slove it because I faced the issue as well last week.

from ggqc.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.