Created
April 13, 2016 06:01
-
-
Save symbolrush/2510d32d8d3acd3d5592227bc23bb7f4 to your computer and use it in GitHub Desktop.
subsetting (filtering) of df's
This file contains hidden or 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
# Testdaten | |
df <- data.frame(category = c(1,2,3,1,3,2,1), value = rep(10, 7)) | |
# Variante 1: | |
# Die Klassiker | |
df[df$category == 2,] | |
subset(df, category == 2) | |
# Variante 2: | |
# mit dem dplyr package. Unterschied: die Zeilen bekommen neue fortlaufende Nummern | |
# das kann Vorteile bieten.. | |
filter(df, category == 2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment