diff --git a/Oblig1/Coop_raw_98.xlsx b/Oblig1/Coop_raw_98.xlsx new file mode 100644 index 0000000..da23c2d Binary files /dev/null and b/Oblig1/Coop_raw_98.xlsx differ diff --git a/Oblig1/Coop_raw_XY.xlsx b/Oblig1/Coop_raw_XY.xlsx deleted file mode 100644 index 4437ac2..0000000 Binary files a/Oblig1/Coop_raw_XY.xlsx and /dev/null differ diff --git a/Oblig1/Laban_raw_98.xlsx b/Oblig1/Laban_raw_98.xlsx new file mode 100644 index 0000000..9644c76 Binary files /dev/null and b/Oblig1/Laban_raw_98.xlsx differ diff --git a/Oblig1/Laban_raw_XY.xlsx b/Oblig1/Laban_raw_XY.xlsx deleted file mode 100644 index 2825a4e..0000000 Binary files a/Oblig1/Laban_raw_XY.xlsx and /dev/null differ diff --git a/Oblig1/Oblig 1a - Datatyper.pdf b/Oblig1/Oblig 1a - Datatyper.pdf new file mode 100644 index 0000000..b52a58f Binary files /dev/null and b/Oblig1/Oblig 1a - Datatyper.pdf differ diff --git a/Oblig1/Sigmenn.R b/Oblig1/Sigmenn.R index 746f972..6ea71d4 100644 --- a/Oblig1/Sigmenn.R +++ b/Oblig1/Sigmenn.R @@ -1,13 +1,148 @@ library(readxl) -b1 <- read_excel("Book1.xlsx") +library(dplyr) +library(ggplot2) + +laban <- read_excel("Laban_raw_98.xlsx") +coop <- read_excel("Coop_raw_98.xlsx") + + +#Finner kolonne-navn +names(laban) +names(coop) + + +#Frekvenser +freq_laban <- laban %>% + count(Lengde) %>% + arrange(Lengde) + +#Velger å trekke fra de tre første radene i coop tabellen +#Gjør dette for å få et mer representativt bilde av dataen +#De tre første strekkene var ikke like metode som resten +freq_coop <- coop %>% + slice(4:n()) %>% + count(Lengde) %>% + arrange(Lengde) + +freq_laban +freq_coop + + +freq_diag_laban <- ggplot(freq_laban, aes(x=`Lengde`, y=n)) + + geom_col() + + geom_vline(aes(xintercept=mid_laban, color="Middelverdi (x̄)"), linewidth=0.9) + + geom_vline(aes(xintercept=med_laban, color="Median (x̃)"), linewidth=0.9) + + geom_vline(aes(xintercept=type_laban, color="Typetall (x_max)"), linewidth=0.9) + + geom_vline(aes(xintercept=mid_laban - sd_laban, color="x̄ − s"), linewidth=0.9, linetype="dashed") + + geom_vline(aes(xintercept=mid_laban + sd_laban, color="x̄ + s"), linewidth=0.9, linetype="dashed") + + labs(title="Frekvensdiagram - Laban", x="Lengde", y="Antall", color="Linjer") + + theme_minimal() + theme(legend.position="bottom") + +freq_diag_coop <- ggplot(freq_coop, aes(x=`Lengde`, y=n)) + + geom_col() + + geom_vline(aes(xintercept=mid_coop, color="Middelverdi (x̄)"), linewidth=0.9) + + geom_vline(aes(xintercept=med_coop, color="Median (x̃)"), linewidth=0.9) + + geom_vline(aes(xintercept=type_coop, color="Typetall (x_max)"), linewidth=0.9) + + geom_vline(aes(xintercept=mid_coop - sd_laban, color="x̄ − s"), linewidth=0.9, linetype="dashed") + + geom_vline(aes(xintercept=mid_coop + sd_laban, color="x̄ + s"), linewidth=0.9, linetype="dashed") + + labs(title="Frekvensdiagram - Coop", x="Lengde", y="Antall", color="Linjer") + + theme_minimal() + theme(legend.position="bottom") + + +freq_diag_laban +freq_diag_coop + + +#Kumulative frekvenser +cum_laban <- freq_laban %>% + mutate(Kumulativ_frekvens = cumsum(n)) + +cum_coop <- freq_coop %>% + mutate(Kumulativ_frekvens = cumsum(n)) + +cum_laban +cum_coop + + +#Kumulative frekvensdiagrammer +cum_diag_laban <- ggplot(cum_laban, aes(x=`Lengde`, y=Kumulativ_frekvens)) + + geom_step(linewidth=0.9) + + geom_vline(aes(xintercept=mid_laban, color="Middelverdi (x̄)"), linewidth=0.9) + + geom_vline(aes(xintercept=med_laban, color="Median (x̃)"), linewidth=0.9) + + geom_vline(aes(xintercept=type_laban, color="Typetall (x_max)"), linewidth=0.9) + + geom_vline(aes(xintercept=mid_laban - sd_laban, color="x̄ − s"), linewidth=0.9, linetype="dashed") + + geom_vline(aes(xintercept=mid_laban + sd_laban, color="x̄ + s"), linewidth=0.9, linetype="dashed") + + labs(title="Kumulativt frekvensdiagram - Laban", x="Lengde", y="Kumulativ frekvens", color="Linjer") + + theme_minimal() + theme(legend.position="bottom") + +cum_diag_coop <- ggplot(cum_coop, aes(x=`Lengde`, y=Kumulativ_frekvens)) + + geom_step(linewidth=0.9) + + geom_vline(aes(xintercept=mid_coop, color="Middelverdi (x̄)"), linewidth=0.9) + + geom_vline(aes(xintercept=med_coop, color="Median (x̃)"), linewidth=0.9) + + geom_vline(aes(xintercept=type_coop, color="Typetall (x_max)"), linewidth=0.9) + + geom_vline(aes(xintercept=mid_coop - sd_laban, color="x̄ − s"), linewidth=0.9, linetype="dashed") + + geom_vline(aes(xintercept=mid_coop + sd_laban, color="x̄ + s"), linewidth=0.9, linetype="dashed") + + labs(title="Kumulativt frekvensdiagram - Laban", x="Lengde", y="Kumulativ frekvens", color="Linjer") + + theme_minimal() + theme(legend.position="bottom") + +cum_diag_laban +cum_diag_laban + + + + +#Medianer +mid_laban <- sum(cum_laban$Lengde*cum_laban$n) / sum(cum_laban$n) +mid_laban + +mid_coop <- sum(cum_coop$Lengde*cum_coop$n) / sum(cum_coop$n) +mid_coop + +med_pos_laban <- sum(cum_laban$n + 1) / 2 +med_pos_laban +med_laban <- cum_laban$Lengde[which(cumsum(cum_laban$n) >= med_pos_laban)[1]] + +med_pos_coop <- sum(cum_coop$n + 1) /2 +med_pos_coop +med_coop <- cum_coop$Lengde[which(cumsum(cum_coop$n) >= med_pos_coop)[1]] + +med_coop +med_laban + + +#Typetall +type_laban <- freq_laban$Lengde[which.max(freq_laban$n)] +type_coop <- freq_coop$Lengde[which.max(freq_coop$n)] + +type_laban +type_coop + + +#Standardavvik +sd_laban <- sd(laban$Lengde) +sd_coop <- sd(coop$Lengde) + +sd_laban +sd_coop + + +#Oppsummering +tabell_laban <- data.frame(Mål = c("Middelverdi", "Median", "Typetall", "Standardavvik"), + Verdi = c(mid_laban, med_laban, type_laban, sd_laban)) +tabell_coop <- data.frame(Mål = c("Middelverdi", "Median", "Typetall", "Standardavvik"), + Verdi = c(mid_coop, med_coop, type_coop, sd_coop)) +tabell_laban +tabell_coop + +oppsummering <- data.frame(Mål = c("Middelverdi", "Median", "Typetall", "Standardavvik"), + Laban = c(mid_laban, med_laban, type_laban, sd_laban), + Coop = c(mid_coop, med_coop, type_coop, sd_coop)) + +oppsummering$Laban <- round(oppsummering$Laban, 2) +oppsummering$Coop <- round(oppsummering$Coop, 2) + +oppsummering +write.csv2(oppsummering, "oppsummering.csv", row.names = FALSE) -list1 = c(b1$Entry) -list2 = c(b1$Data) -mean.default(list1) -mean(list2) - -summary(b1) -BookLaban <- read_excel("Laban_raw_XY.xlsx") -View(BookLaban) diff --git a/Oblig1/cumlab.svg b/Oblig1/cumlab.svg new file mode 100644 index 0000000..8ae56f5 --- /dev/null +++ b/Oblig1/cumlab.svg @@ -0,0 +1,523 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Oblig1/kum_coop.svg b/Oblig1/kum_coop.svg new file mode 100644 index 0000000..50f2af4 --- /dev/null +++ b/Oblig1/kum_coop.svg @@ -0,0 +1,411 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Oblig1/kum_laban.svg b/Oblig1/kum_laban.svg new file mode 100644 index 0000000..2461fac --- /dev/null +++ b/Oblig1/kum_laban.svg @@ -0,0 +1,393 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +