How to do it...

Wrapping code for sharing and reuse can be done using the following steps:

  1. Load an existing source code file:
source(file.path(getwd(), "datasets", "ch11", "my_source_file.R"))
my_sourced_function()
  1. Create a package skeleton:
usethis::create_package("newpackage")
  1. Write code:
my_package_function <- function(x){
return( c("I come from a package!") )
}
  1. Load the package code into memory:
devtools::load_all()
  1. Install the package into your current R installation:
devtools::install()
library(newpackage)
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.249.127