Summarize dplyr1/6/2023 ![]() You can rename variables with select() by using named These let you quickly match larger blocks of There are a number of helper functions you can use withinĬontains(). ![]() ![]() # Select columns by name starwars %>% select(hair_color, skin_color, eye_color) #> # A tibble: 87 × 3 #> hair_color skin_color eye_color #> #> 1 blond fair blue #> 2 gold yellow #> 3 white, blue red #> 4 none white yellow #> # … with 83 more rows # Select all columns between hair_color and eye_color (inclusive) starwars %>% select(hair_color :eye_color) #> # A tibble: 87 × 3 #> hair_color skin_color eye_color #> #> 1 blond fair blue #> 2 gold yellow #> 3 white, blue red #> 4 none white yellow #> # … with 83 more rows # Select all columns except those from hair_color to eye_color (inclusive) starwars %>% select( !(hair_color :eye_color)) #> # A tibble: 87 × 11 #> name height mass birth…¹ sex gender homew…² species films vehic…³ stars…⁴ #> #> 1 Luke … 172 77 19 male mascu… Tatooi… Human #> 2 C-3PO 167 75 112 none mascu… Tatooi… Droid #> 3 R2-D2 96 32 33 none mascu… Naboo Droid #> 4 Darth… 202 136 41.9 male mascu… Tatooi… Human #> # … with 83 more rows, and abbreviated variable names ¹birth_year, ²homeworld, #> # ³vehicles, ⁴starships # Select all columns ending with color starwars %>% select( ends_with( "color")) #> # A tibble: 87 × 3 #> hair_color skin_color eye_color #> #> 1 blond fair blue #> 2 gold yellow #> 3 white, blue red #> 4 none white yellow #> # … with 83 more rows With highest or lowest values of a variable.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |