Back to Course
Package Development with R
0% Complete
0/0 Steps
-
Welcome, Logistics, Course Materials, and Additional Resources
-
Setup packagesdevtools and usethis
-
Package names and authors
-
Choose a license
-
Setup git + GitHub
-
Write codeWriting functions
-
Adding functions to our package
-
Using other packages
-
Packages so good they get their own functions
-
Organizing .R files
-
Documentroxygen2: In-Line Documentation for R
-
Argument descriptions and examples
-
Helper functions
-
Joining documentation
-
TestUnit tests for R
-
Organizing tests
-
R CMD Check
-
Types of Test Files
-
Test Coverage
-
TeachExamples
-
README
-
Spellcheck
-
Add data and filesStore data and files
-
Include data for tests and create RMarkdown templates
-
Create other templates
-
Launch and store Shiny apps
-
Citations, ignoring files, and including add-ins
Lesson 7 of 27
In Progress
Adding functions to our package
Your Turn 2
- Create a new file with use_r() called “db_con”
- Put this function in the file and save it
- Use load_all() to load the package function.
- Run this code to make sure it works
use_r("db_con")
in R/db_con.R:
db_con <- function(dbname = "residents_per_sector") {
dbname <- match.arg(dbname)
# We'll pretend we've connected to a database
# and just return some hard-coded data instead.
data.frame(
sector = as.factor(1:8),
residents = c(1000, 2034, 4594, 2304, 8093, 1200, 300, 2398))
}
Have any questions? Put them below and we will help you out!