33 lines
985 B
R
33 lines
985 B
R
# Projekt 1: Przygotowanie wizualnej analizy danych z wykorzystaniem podstawowej biblioteki graficznej R i/lub biblioteki ggplot2
|
|
# zaladowanie bibliotek
|
|
library(Hmisc)
|
|
library(dplyr)
|
|
library(ggplot2)
|
|
library(RColorBrewer)
|
|
|
|
# zaladowanie danych
|
|
german_credit_risk <- read.csv("german_credit_data.csv", header = TRUE)
|
|
|
|
# sprawdzenie danych
|
|
head(german_credit_risk)
|
|
tail(german_credit_risk)
|
|
str(german_credit_risk)
|
|
summary(german_credit_risk)
|
|
describe(german_credit_risk)
|
|
|
|
# zmiana nazwy pierwszej kolumny
|
|
colnames(german_credit_risk)[1] <- "index"
|
|
|
|
min(german_credit_risk$Age)
|
|
na.omit(german_credit_risk)
|
|
|
|
# violin plot
|
|
ggplot(german_credit_risk, aes(x=Purpose, y=Age, fill=Sex)) +
|
|
geom_violin(trim=TRUE, position=position_dodge(1)) +
|
|
stat_summary(fun = mean, geom="point", shape=25, size=2) + #position=position_dodge(.9)
|
|
labs(title="Credit purpose by age", x="Purpose", y = "Age") +
|
|
scale_fill_brewer(palette="Accent") +
|
|
theme_minimal() +
|
|
theme(legend.position="bottom")
|
|
|