Personal R package of Ben Cunningham.
This repository is a compilation of functions that I find useful. It is inspired by Hilary Parker's article Personal R Packages. To get started creating your own packages, I recommend her tutorial.
This project is subject to change erratically, so it would be unwise to rely on anything here as a long-term dependency. Feel free to clone anything you find particularly valuable for use in your own personal function repo.
devtools::install_github("benjcunningham/ben")
The following options should be set in .Rprofile
to customize the default behaviour of some functions.
ben.alarms
: Directory of sound assets; for example~/R/alarms/
ben.alarmdefault
: Default sound file to play; for exampleHangouts.wav
To take advantage of the Pushbullet notification wrappers, RPushbullet
should be configured with ~/.rpushbullet.json
or equivalent global options. In the past, it was necessary to attach RPushbullet
to make API calls; this is no longer the case, but you must set options in the JSON dotfile.
To serve Jekyll blog posts that contain JavaScript frames (e.g. Leaflet), follow the following workflow:
- Write the post using R Markdown and save it in a non-served project directory like
_R
. Include only YAML front matter that pertains to rendering the document as HTML. For example, in the file_R/test-post.Rmd
:
---
output:
html_document:
theme: null
self_contained: true
---
Hello world!
- If using the default directories, make sure an
_includes/htmlwidgets
directory exists before proceeding. Render the post as HTML using:
ben::knit_htmlwidgets("./_R/test-post.Rmd")
- Create a placeholder R Markdown file in your regular post directory (usually
_source
). Include regular YAML front matter and a Jekyll liquid include to the rendered HTML post. For example, in the file_source/2016-01-01-test-post.Rmd
:
---
layout: post
title: "Test Post"
date: "January 1, 2016"
---
{% include htmlwidgets/test-post.html %}
- Build the site with
servr::jekyll()
.
For more information, see the post Hacking Together htmlwidgets for Jekyll.