Packages so good they get their own functions
This lesson is called Packages so good they get their own functions, part of the Package Development with R course. This lesson is called Packages so good they get their own functions, part of the Package Development with R course.
Transcript
Click on the transcript to go to that point in the video. Please note that transcripts are auto generated and may contain minor inaccuracies.
Your Turn
We need roxygen2 for this exercise. We’ll learn more about it in the next module. For now, just run use_roxygen_md()
Run use_tibble() and use_data_table()
In R/get_data.R, edit the function to be able to return a data table: Add the argument data_table = FALSE. If data_table is TRUE, convert the data frame with data.table::as.data.table()
Load the package and run this code to make sure it works
use_roxygen_md()
use_tibble()
use_data_table()
get_resident_data <- function(data_table = FALSE) {
residents_per_sector <- db_con("residents_per_sector")
if (data_table)
return(data.table::as.data.table(residents_per_sector))
tibble::as_tibble(residents_per_sector)
}
Your Turn 4 Stretch Goal
Run use_pipe() to add the magrittr pipe to your package. What changed?
Have any questions? Put them below and we will help you out!
Course Content
27 Lessons
You need to be signed-in to comment on this post. Login.