brad-cannell / r4epi

Repository for the R for Epidemiology book
http://www.r4epi.com/
Other
23 stars 51 forks source link

Discuss print to screen vs. assign with pipes #137

Open mbcann01 opened 8 months ago

mbcann01 commented 8 months ago

Show them how to print without assigning. There is a lot of confusion about this. Add to the pipes chapter. Also, add that you can do both by adding print() to the end of the pipeline.

mtcars %>%
  mutate(mpg = mpg + 1)

mtcars <- mtcars %>%
 mutate(mpg = mpg + 1)

mtcars <- mtcars %>%
 mutate(mpg = mpg + 1) %>%
 print()