boxplot
This commit is contained in:
parent
e7269d268a
commit
b3791c903c
25
projekt.R
25
projekt.R
@ -43,3 +43,28 @@ ggplot(german_credit_risk , aes(x = factor(Job), fill = Purpose)) +
|
||||
scale_x_discrete(breaks = 0:3, labels=c("Unskilled, non-resident", "Unskilled, resident","Skilled","Highly skilled")) +
|
||||
labs(title="Credit count and purpose for different job statuses", x="Job status", y = "Credit count") +
|
||||
theme_minimal()
|
||||
|
||||
#Wykres pudełkowy przedstawiający jakiej wielkości najczęściej ludzie biorą kredyty na poszczególne cele.
|
||||
stat_box_data <- function(y) {
|
||||
return(
|
||||
data.frame(
|
||||
y = max(german_credit_risk$Credit.amount),
|
||||
label = paste('count =', length(y), '\n',
|
||||
'sum =', sum(y), '\n')
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
german_credit_risk %>%
|
||||
mutate(Purpose = reorder(Purpose, Credit.amount, sum)) %>%
|
||||
ggplot(aes(x = Purpose, y = Credit.amount, fill = Purpose)) +
|
||||
geom_boxplot(alpha = .7) +
|
||||
guides(fill = "none") +
|
||||
scale_y_continuous(breaks = scales::pretty_breaks(n = 10)) +
|
||||
stat_summary(
|
||||
fun.data = stat_box_data,
|
||||
geom = "text",
|
||||
vjust = 1
|
||||
) +
|
||||
ylab("Credit amount") +
|
||||
theme_bw()
|
||||
|
Loading…
Reference in New Issue
Block a user