# basics + - * / ^ 5+3 5^3 (5+3)^2 # basics < > == ! & | 5 == 5 7 < 5 7 >= 7 TRUE & FALSE TRUE | FALSE !TRUE !( 5 %in% c(3,4,5) ) # Kombinatorik # Erstellen von Vektoren c(3,5,7,9) v1 <- 1:8 v2 = 8:1 # Rechnen mit Vektoren v1*v2 v1/v2 v1%*% t(v2) t(v1) %*% v2 # konkatenieren c(v1,v2) cbind(v1,v2) rbind(v1,v2) # weitere spezielle Vektoren rep( c(1,2,3), times = 3) rep( c(1,2,3), each = 3) seq(0,1, 0.05) # >> Laenge von Vektoren/Objekten und Dimension einer Matrix/eines Datensatzes length(v1) dim(v1%*% t(v2)) # Laden eines Datensatzes -> Menu oder... eco09<-read.table("http://www.rosuda.org/lehre/SS10-f/Datensaetze/EcoTestAuto09.txt",sep="\t",header=T,quote="") attach(eco09) # Zugriff auf Datensaetze, Matrizen und Vektoren eco09$Verbrauch eco09[,4] eco09[5,4] Verbrauch # mit attach(eco09) v3 <- eco09$Punkte.CO2 v3[3:5] # Zugriff auf Listen listeA <- list( letters[3:5], 7, summary(Verbrauch) ) listeA[[1]] # Informationen zum Datensatz im Object.Browser oder zB names(eco09) attributes(eco09) dim(eco09) # Erstellen eine summary jeder Variable abhaenig vom Datentyp: integer, numeric, factor , logical, ... summary(eco09) # einfache Statistiken # >> Mittelwert und Standardabweichung mean(eco09$kW) mean(kW) # wenn eco09 attached ist (s.o.) sd(kW) var(kW) # tables table(Typ) table(Typ,Klasse) # einfache Grafiken # >> Histogramm hist(Verbrauch) # >> barcharts barplot( table(Typ) ) # >> Streudiagramme (scatterplots) plot( Punkte.CO2 ~ Punkte.Schadstoffe )