knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
This repo is the home of an R package that helps me create routes. It is provided with minimal documentation and no guarantees.
If you would like me to create something for you, or you just want a print of something I've already made, head to my Etsy store.
You can install the development version from GitHub with:
# install.packages("remotes") remotes::install_github("cwickham/routes")
routes assumes you have a Google API key stored in the environment variable GOOGLE_API_KEY
. Get an API key from google, then run:
usethis::edit_r_environ()
to open your .Renviron
file and add a line of the form:
GOOGLE_API_KEY="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
Open a new RStudio project and run setup()
:
routes::setup(from = "Corvallis, OR", to = "Portland, OR", shortname = "oregon")
You need to specify from
and to
as strings understandable to Google Maps as locations. setup()
creates a folder called shortname/
and creates a 00-setup.R
file inside this directory. (routes uses here::here()
extensively in its templates under the assumption that shortname/
is in the root directory of your project).
00-setup.R
will open for editing. You will see the three required steps for creating a route.
Run each step to create and open a new file, run the code in the file to complete the step.
An example of running through these steps can be found in oregon/
. In particular, you can see the result of Knitting the steps in the following files:
# Run to regenerate `oregon/` example routes::setup(from = "Corvallis, OR", to = "Portland, OR", shortname = "oregon") source(here::here("oregon", "00-setup.R")) rmarkdown::render(here::here("oregon", "01-route.Rmd")) rmarkdown::render(here::here("oregon", "02-streetview.Rmd")) rmarkdown::render(here::here("oregon", "03-cluster.Rmd")) fs::file_copy(here::here("oregon", "oregon_route.jpeg"), here::here("man/figures/README-oregon_route.jpeg"), overwrite = TRUE)
I've provided this package publicly because I'd love you to create your own artworks. If you do, please credit me for the original code, and support me by sending people to my Etsy store.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.