lehrkraefte:ks:ffstat2122:start

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
lehrkraefte:ks:ffstat2122:start [2022/06/24 14:57]
Simon Knaus
lehrkraefte:ks:ffstat2122:start [2022/06/24 17:10]
Simon Knaus
Line 14: Line 14:
  
 === Aufträge === === Aufträge ===
-  * [[https://bldsg-my.sharepoint.com/:x:/g/personal/simon_knaus_ksbg_ch/EViLCgTgPtJDv_0n0KTreCIBGpi9za5FMOXOOKMExuwNzA?e=Xff4cc|Daten]] herunterladen und einlesen und <<inspizieren>>. Was fällt auf? Sind die Daten so realistisch? In R ggf. mit ''summary''+  * [[https://bldsg-my.sharepoint.com/:u:/g/personal/simon_knaus_ksbg_ch/EYGR9VHkuSdMs1h-J5_CUKsBm2z8nBGPCz321xhSkHiVHQ?e=OilJzV|Daten]] herunterladen und einlesen und <<inspizieren>>. Was fällt auf? Sind die Daten so realistisch? In R ggf. mit ''summary''
   * Analysen auswählen   * Analysen auswählen
     * Welche Analysen sind in welcher Variabel-Konstellation möglich? (Nominal, ordinale, kardinale Variablen)     * Welche Analysen sind in welcher Variabel-Konstellation möglich? (Nominal, ordinale, kardinale Variablen)
Line 29: Line 29:
 === Daten einlesen und recodieren in R === === Daten einlesen und recodieren in R ===
  
-Idealerweise werden die Zeilenspaltentitel bereits in Excel angepasst. Damit hat man kurze Variabelnamen und man kann dann mit ''read.table(file('clipboard'), sep='\t')'' die Daten einlesen.+Idealerweise werden die Zeilenspaltentitel bereits in Excel angepasst. Damit hat man kurze Variabelnamen und man kann dann mit ''read.table(file('clipboard'), sep='\t',header=T)'' die Daten einlesen.
  
 Sind die Daten eingelesen, kann mit  Sind die Daten eingelesen, kann mit 
 <code python> <code python>
-gluecksdata <- read.table(file('clipboard'), sep='\t')+gluecksdata <- read.table(file('clipboard'), sep='\t',header=T)
 # Recodieren # Recodieren
 # Annahme die 8. Spalte hat neu den Titel 'allinall' # Annahme die 8. Spalte hat neu den Titel 'allinall'
Line 39: Line 39:
 </code> </code>
  
 +<hidden Mögliche Lösung>
 +<code>
 +data <- read.table(file("clipboard"),sep="\t",header=T)
 +head(data)
 +library(ggplot2)
 +names(data)
 +#gesamtglück
 +data$overall <- with(data,(insgesamt.+lately.+happylife+happymonth+happyoverall)/5)
 +#glück vs. aussehen
 +ggplot(data,aes(y=overall,x=looks))+geom_point()+geom_smooth(method="lm",se = F)
 +#glück vs. gesundheit
 +ggplot(data,aes(y=overall,x=health))+geom_point()+geom_smooth(method="lm",se = F)
 +#glück vs. sleep
 +ggplot(data,aes(y=overall,x=sleep))+geom_point()+geom_smooth(method="lm",se = F)
 +ggplot(subset(data,sleep<30),aes(y=overall,x=sleep))+geom_point()+geom_smooth(method="lm",se = F)
 +
 +with(subset(data,sleep<30),cor(overall,sleep,use = "pairwise.complete"))
 +ggplot(data,aes(y=overall,x=free))+geom_point()+geom_smooth(method="lm",se = F)
 +ggplot(subset(data,free<30),aes(y=overall,x=free))+geom_point()+geom_smooth(method="lm",se = F)
 +ggplot(data,aes(y=overall,x=social))+geom_point()+geom_smooth(method="lm",se = F)
 +ggplot(subset(data,social<30),aes(y=overall,x=social))+geom_point()+geom_smooth(method="lm",se = F)
 +ggplot(data,aes(y=overall,x=sport))+geom_point()+geom_smooth(method="lm",se = F)
 +ggplot(data,aes(x=overall))+geom_histogram(position = "identity")+facet_grid(gender~.)
 +ggplot(data,aes(x=overall,y=gender))+geom_boxplot()
 +ggplot(data,aes(y=overall,x=age))+geom_point()+geom_smooth(method="lm",se = F)
 +ggplot(data,aes(x=meanin,y=overall))+geom_boxplot()
 +ggplot(data,aes(x=morning,y=overall))+geom_boxplot()
 +ggplot(data,aes(x=morning,y=overall))+geom_violin()
 +ggplot(data,aes(x=important,y=overall))+geom_boxplot()
 +library(corrplot)
 +relvar <- sapply(data,is.numeric)
 +corrplot(cor(subset(data[,relvar],free<30),use="pairwise.complete")) 
 +ggplot(da)
 +
 +
 +</code>
 +</hidden>
  
 ==== Lektion 13 ==== ==== Lektion 13 ====
  • lehrkraefte/ks/ffstat2122/start.txt
  • Last modified: 2023/06/01 09:40
  • by Simon Knaus