Transforming data with dplyr

Once data is tidy, you can use dplyr to further transform your data.

The below documentation covers six fundamental dpylr functions that should allow you to perform the majority of data wrangling tasks. You can learn about:

Throughout these examples, using the palmerpenguins data, you will see the head() function used as a way to confirm the effect of the data transformations.

You can also use head() to get a sense of your dataset, variables, and values:

head(penguins)
## # A tibble: 6 x 8
##   species island bill_length_mm bill_depth_mm flipper_length_… body_mass_g sex  
##   <fct>   <fct>           <dbl>         <dbl>            <int>       <int> <fct>
## 1 Adelie  Torge…           39.1          18.7              181        3750 male 
## 2 Adelie  Torge…           39.5          17.4              186        3800 fema…
## 3 Adelie  Torge…           40.3          18                195        3250 fema…
## 4 Adelie  Torge…           NA            NA                 NA          NA <NA> 
## 5 Adelie  Torge…           36.7          19.3              193        3450 fema…
## 6 Adelie  Torge…           39.3          20.6              190        3650 male 
## # … with 1 more variable: year <int>

If you want to learn more about dplyr, the package's website contains a more extensive overview of the package and its functions. You might also check out the data transformation chapter of the R for Data Science book.