Created
January 22, 2013 15:16
-
-
Save Su-Shee/4595381 to your computer and use it in GitHub Desktop.
example R code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# And what's the largest number of men and women in any neighbourhood? | |
max(aggregate(csv$Anzahl, by = list(csv$Bezirk), FUN = sum)[[2]]) | |
# That doesn't really help, does it? So, display more information - in | |
# which row do we have the highest number? | |
which.max(aggregate(csv$Anzahl, by = list(csv$Bezirk), FUN = sum)[[2]]) | |
# Still no use - let's display the entire row: | |
allHoods <- aggregate(csv$Anzahl, by = list(csv$Bezirk), FUN = sum) | |
maxRow <- which.max(allHoods[[2]]) | |
allHoods[maxRow,] | |
# In which neighbourhood live the most women? | |
femaleMax <- which.max(allHoods[ grep("f", allHoods$Group.2), ][[3]]) | |
allHoods[femaleMax,] | |
# And some basic descriptive statistics for the women in Berlin: | |
summary(allHoods[ grep("f", allHoods$Group.2), ][[3]]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment