| tags: [ R R packages Rmarkdown ] categories: [Administration Coding ]
Some basics for getting started with your new blogdown lab notebook
Global options
It’s a good idea to set some global default options.
# setting some default options
options(blogdown.ext = '.Rmd', blogdown.subdir = 'posts')
NOTE: to avoid running this each session it is best to set these options in your .Rprofile so they take effect when launching RStudio
- see https://bookdown.org/yihui/blogdown/global-options.html for details around this
Dynamic (live updating) previews of your site
At the start of each session make sure you run the serve function. With this running you will be able to see in real-time all the changes that you make to your notebook site.
# serve the website
blogdown::serve_site()
Creating new entries
The following code snippets demonstrate creating new entries (notebook ‘posts’) under several different categories - also remember that if you are using RStudio with blogdown installed then you have access to some addins which can do this for you in a more user-friendly manner.
IMPORTANT: Remember that this notebook is set up in such a way that entries are recorded and listed under user defined categories. I suggest picking a handful of major categories (examples below) and only having an entry under one or two of these, then use the tag options to further list any keywords or searchvterms that you wish to associate with the entry. This system allows for quick easy searching and locating of specific entries. The home page lists all recent entries by date (newest first).
Say I want an entry to appear under the category ‘Experiment’:
# create a new entry under the category 'Experiment'
blogdown::new_post(title = 'Introduction to RMarkdown',
date = '2018-04-01',
ext = '.Rmd',
subdir = 'posts',
author = 'Your Name',
categories = c('Experiment'),
tags = c('R', 'Rmarkdown'))
I’ve done some reading and want to record some notes under a ‘Reading’ category:
# create a new entry under the category 'Reading'
blogdown::new_post(title = 'Summary of a fantastic review paper',
date = '2018-02-11',
ext = '.Rmd',
subdir = 'posts',
author = 'Your Name',
categories = c('Reading'),
tags = c('Reading', 'Literature'))
I’m creating a category call ‘Writing’ and documenting the joys of Authorea:
# create a new entry under the category 'Writing'
blogdown::new_post(title = 'Collaborative writing online using Authorea',
date = '2018-03-20',
ext = '.Rmd',
subdir = 'posts',
author = 'Your Name',
categories = c('Writing'),
tags = c('Writing', 'Authorea'))
I’ve performed a simple linear regression experiment and want to list it under ‘Experiments’:
## if you have global options set (as above) you can use the following:
# adding a post on regression analysis to the Experiment category
blogdown::new_post(title = 'Performing simple linear regressions in R',
date = '2018-03-28',
author = 'Your Name',
categories = c('Experiment'),
tags = c('R', 'Regression', 'Analysis'))
I’ve integrated some python code into my R workflow, I’ll file this under a category called ‘Coding’:
# creating a post on the reticulate package in the category coding
blogdown::new_post(title = 'Integrating Python into your R code with reticulate',
date = '2018-03-27',
author = 'Your Name',
categories = c('Coding'),
tags = c('R', 'R packages', 'reticulate', 'Python'))