Advertisement
federico_carosio

Untitled

Dec 3rd, 2024
10
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. data_noNA <- data %>%
  2. mutate(`Intentional Release (Barrels)` = ifelse(is.na(`Intentional Release (Barrels)`), 0, `Intentional Release (Barrels)`)) %>%
  3. filter(!is.na(`Accident State`))
  4.  
  5. ds_efficiency <- data_noNA %>%
  6. group_by(`Accident State`) %>%
  7. summarize(
  8. mean_percentage = mean(((`Liquid Recovery (Barrels)`) / (`Unintentional Release (Barrels)`+`Intentional Release (Barrels)`)), na.rm = TRUE) # Calcolo percentuale e media
  9. )
  10.  
  11.  
  12.  
  13. ggplot(ds_efficiency, aes(x = reorder(`Accident State`, mean_percentage), y = mean_percentage)) +
  14. geom_bar(stat = "identity") +
  15. labs(
  16. title = "EFFICIENZA DI RECUPERO MEDIO DI BARILI PER OGNI STATO",
  17. x = "STATO",
  18. y = "FREQUENZA"
  19. ) +
  20. theme_minimal()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement