diff --git a/ch420_statistics/.gitignore b/ch420_statistics/.gitignore new file mode 100644 index 0000000..6760daf --- /dev/null +++ b/ch420_statistics/.gitignore @@ -0,0 +1,4 @@ +.Rproj.user +.Rhistory +.RData +main.html diff --git a/ch420_statistics/ch420_statistics.Rproj b/ch420_statistics/ch420_statistics.Rproj new file mode 100644 index 0000000..ffefba4 --- /dev/null +++ b/ch420_statistics/ch420_statistics.Rproj @@ -0,0 +1,13 @@ +Version: 1.0 + +RestoreWorkspace: No +SaveWorkspace: No +AlwaysSaveHistory: No + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: Sweave +LaTeX: pdfLaTeX diff --git a/ch420_statistics/main.R b/ch420_statistics/main.R new file mode 100644 index 0000000..563bee5 --- /dev/null +++ b/ch420_statistics/main.R @@ -0,0 +1,24 @@ +library(mongolite) +m <- mongo(db="heroku_t242kdp0", collection = "supporters") + + +all <- m$find('{"duplicate": { "$ne": true }}') +all$created_at <- as.Date(all$created_at) +all <- subset(all, created_at >= as.Date('2016-04-20')) + +barplot(table(all$created_at), main = "Verlauf Einträge #CH420 Total") + +li_members <- subset(all, li_membership == T) + +barplot(table(li_members$created_at), main = "Verlauf Einträge #CH420 Mitgliedschaft") + + +ages <- table(all$age_category) +percentlabels<- round(100*ages/sum(ages), 1) +pielabels<- paste(percentlabels, "%", sep="") +cols <- rainbow(4) +pie(ages, main="Altersverteilung #CH420", col=cols, labels=pielabels, cex=0.8, sub=paste("N =", sum(ages))) +legend("topright", c("30-64",">64","< 18","18-30"), cex=0.8, fill=cols) + + + diff --git a/ch420_statistics/main.Rmd b/ch420_statistics/main.Rmd new file mode 100644 index 0000000..a7ad2ee --- /dev/null +++ b/ch420_statistics/main.Rmd @@ -0,0 +1,31 @@ +--- +title: '#CH420 Statistiken Onlineforumlar' +author: "Markus Graf" +date: "23. April 2016" +output: html_document +--- + + +```{r} +library(mongolite) +m <- mongo(db="heroku_t242kdp0", collection = "supporters") + + +all <- m$find('{"duplicate": { "$ne": true }}') +all$created_at <- as.Date(all$created_at) +all <- subset(all, created_at >= as.Date('2016-04-20')) + +barplot(table(all$created_at), main = "Verlauf Eintraege #CH420 Total") + +li_members <- subset(all, li_membership == T) + +barplot(table(li_members$created_at), main = "Verlauf Eintraege #CH420 Mitgliedschaft") + + +ages <- table(all$age_category) +percentlabels<- round(100*ages/sum(ages), 1) +pielabels<- paste(percentlabels, "%", sep="") +cols <- rainbow(4) +pie(ages, main="Altersverteilung #CH420", col=cols, labels=pielabels, cex=0.8, sub=paste("N =", sum(ages))) +legend("topright", c("30-64",">64","< 18","18-30"), cex=0.8, fill=cols) +``` \ No newline at end of file