This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
# 1.) Erste Inspektion der Daten
#Einlesen der daten in den Vektor gpa
gpa <- read.csv( "http://roycekimmons.com/system/generate_data.php?dataset=exams&n=100")
#erstellen eines Barcharts des math.score
hist(gpa$math.score)
#erstellen eines Barcharts des reading.score
hist(gpa$reading.score)
#erstellen eines Barcharts des writing.score
hist(gpa$writing.score)
#MATH.SCORE PRÜFEN AUF NORMALVERTEILUNG
#freq=FALSE wird angewendet, damit auf der y-Achse nicht mehr die Häufigkeiten,
#sondern die Dichte abgebildet wird
#wird x zugeordnet, weil diese variable in curve() gebraucht wird.
#breaks=seq legt intervall von 30-100 auf der x-Achse fest
#length legt Anzahl der Intervalle fest
x <- hist(gpa$math.score,breaks=seq(30,100,length=30), freq=FALSE)
#mittelwert von math.score ermitteln
m <- mean(gpa$math.score)
#Standardabweichung von math.score ermitteln
s <- sd(gpa$math.score)
#Einzeichnen einer Dichtefunktion um Normalverteilung zu prüfen
curve(dnorm(x,m,s),add=TRUE,lwd=3)
# 2.) Übung zur Korrelation
#Einlesen der Daten in die variable gpa
gpa <- read.csv( "http://roycekimmons.com/system/generate_data.php?dataset=exams&n=100")
#Korrelationsanalyse math.score und reading.score
cor(gpa$math.score,gpa$reading.score)
## [1] 0.8689644
#Korrelationsanalyse reading.score und writing.score
cor(gpa$reading.score, gpa$writing.score)
## [1] 0.9690966
#Korrelationsanalyse math.score und writing.score
cor(gpa$math.score, gpa$writing.score)
## [1] 0.8660343
You can also embed plots, for example:
Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.