# ÜBUNG ======================================================== # benötigte Pakete laden library(ggplot2) library(tidyverse) library(dplyr) # Platz für Tests ============================================== library(nycflights13) # Übungsdatensatz glimpse(flights) # ZEILEN ------------------------------------------------------- flights %>% filter() flights %>% arrange() flights %>% distinct() # SPALTEN ------------------------------------------------------ flights %>% mutate() flights %>% select() flights %>% rename() flights %>% relocate() # DIE PIPE ------------------------------------------------------ flights %>% # DIFFERENZBERECHNUNG ============================================ data_path <- ("/Users/franknagel/Documents/Psychologie Bachelor/Semester 2/Programmieren") fname <- file.path(data_path, "Einstichproben-T-Test.csv") # Tabelle erstellen D <- read.table(fname, sep = ",", header = TRUE) # Differenzberechnung bis jetzt----------------------------------- D$Delta.BDI <- (D$Post - D$Pre) # Arbeiten mit dplyr --------------------------------------------- # Datenvorbereitung K <- tibble() View(K) # Differenzberechnung mit mutate K <- K %>% View(K) # VIOLINPLOT ====================================================== ggplot( K, aes(x = "", y = diff_bdi) ) + geom_violin(fill = "grey", color = "black") + geom_jitter(width = 0.1) + labs(title = "Pre Post BDI Differenzwerte", y = "BDI Differenzwerte", x = "") + theme_minimal() # Abbildung speichern ggsave( filename = "Violinplot_Übung.pdf", height = 7, width = 5 )