survival.Rmd
As mom objects are tibbles, they probably look more than familiar to you. And as they are tibbles, the entire tidyverse comes for free.
This vignette illustrates how to use the most common tidyverse functions for the most common data manipulation tasks in MomX. Things shown here will “work” on any data.frame
and can be found easily from the tidyverse homepage: https://www.tidyverse.org/.
First thing first: if you’re not familiar with these %>%
everywhere in my code, examples, etc. let me just show you some “base R”:
bot_c <- coo_center(bot) bot_cs <- coo_scale(bot_c) bot_csa <- coo_align(bot_cs) bot_csa1 <- coo_slidedirection(bot_csa) bot_eft <- efourier(bot_csa1)
And now some “piped R”:
bot %>% coo_center %>% coo_scale %>% coo_align %>% coo_slidedirection("right") %>% efourier()
Unless you’re an ultra-rthodox or something1, you will likely vote for the second one. We should not reduce the pipe-operator to a matter of taste, it is also:
Read the Introduction to magrittr
To be perfectly clear, <mom>
are tibbles that are themselves data.frame
that are themselves list
:
tibble::is_tibble(bot) is.data.frame(bot) is.list(bot)
In other words you do not need tidyverse verbs (they are just really really desirable) to handles <mom>
objects, ie all of this works:
dplyr
: common data manipulationIf you’re not familiar with dplyr, the Introduction to dplyr will definitely change your life.
By our side, we will play with olive stones: