Transcription of Data transformation with dplyr : : CHEAT SHEET
{{id}} {{{paragraph}}}
Data transformation with dplyr : : CHEAT SHEET . dplyr functions work with pipes and expect tidy data. In tidy data: A B C A B C. Manipulate Cases Manipulate Variables &. pipes EXTRACT CASES EXTRACT VARIABLES. Row functions return a subset of rows as a new table. Column functions return a set of columns as a new vector or table. Each variable is in Each observation, or x %>% f(y). its own column case, is in its own row becomes f(x, y) filter(.data, , .preserve = FALSE) Extract rows pull(.data, var = -1, name = NULL, ) Extract Summarise Cases w www ww that meet logical criteria. filter(mtcars, mpg > 20) w www column values as a vector, by name or index. pull(mtcars, wt). distinct(.data, , .keep_all = FALSE) Remove select(.data, ) Extract columns as a table. w www Apply summary functions to columns to create a new table of w www ww rows with duplicate values.
Summarise Cases Use rowwise(.data, …) to group data into individual rows. dplyr functions will compute results for each row. Also apply functions to list-columns. See tidyr cheat sheet for list-column workflow.
Domain:
Source:
Link to this page:
Please notify us if you found a problem with this document:
{{id}} {{{paragraph}}}