vignettes/clamour.Rmd
clamour.Rmd
clamour is a package to help with building a website to display the results of analysis of Twitter hashtags, usually associated with an event such as an academic conference. The package provides some basic infrastructure and examples to help you get set up.
library(clamour)
This vignette will take you through the basics of setting up a clamour project, analysis of an example dataset and how to host the results on a website using GitHub pages.
To start a clamour project we can use the clamour_setup
function. This will create a basic directory structure with some template files. We just need to provide the function with a path to the new project directory. For this vignette we use a temporary directory.
path <- fs::path(tempdir(), "example") clamour_setup(path) #> ✔ Creating '/tmp/Rtmp2EP8XH/example/' #> ✔ Setting active project to '/tmp/Rtmp2EP8XH/example' #> ✔ Creating 'analysis/' #> ✔ Creating 'analysis/figures/' #> ✔ Adding '^analysis/figures$' to '.Rbuildignore' #> ✔ Writing 'analysis/_site.yml' #> ✔ Writing 'analysis/index.Rmd' #> ✔ Writing 'analysis/about.Rmd' #> ✔ Writing 'analysis/_analysis.Rmd' #> ✔ Writing 'analysis/EXAMPLE.Rmd' #> ✔ Creating 'R/' #> ✔ Writing 'R/libraries.R' #> ✔ Writing 'R/knitr-options.R' #> ✔ Creating 'docs/' #> ✔ Creating 'data/' #> ✔ Copying 'data/EXAMPLE.Rds' #> ✔ Writing 'README.md' #> ● Run the following code to make sure rtweet is authorised: #> `rt <- rtweet::search_tweets('#rstats', n = 1000)` #> ✔ Setting active project to '<no active project>'
The result is the following directory structure:
analysis/
- Analysis files for each hashtag
_site.yml
- Website configuration fileindex.Rmd
- Index pageabout.Rmd
- About pageEXAMPLE.Rmd
- An example hashtag analysis file_analysis.Rmd
- Analysis template that is applied to each hashtagdata/
- Data files containing tweets
EXAMPLE.Rds
- The example tweet datasetdocs/
- Rendered website files will go hereWhen you want to add an analysis for a new hashtag or event you should run the clamour_new
function. This function will create a new R Markdown document based on the arguments you have provided. See the EXAMPLE.Rmd
file for an example of what this looks like. Parameters for this analysis are provided in the YAML section at the start of the file (see ?clamour_new
for more description of these). After loading the tweet data there is an introduction where you can describe the analysis in more detail. Most of the analysis is performed by the chunk labelled analysis
which knits the _analysis.Rmd
file. By having the analysis code in a separate file it is easy to update it in one place and apply those changes to every analysis on your website.
To make sure that your new analysis will be accessible our your website remember to render the index.html
file. The template for this file contains a call to clamour_list()
which should automatically add a link to your new analysis.
Individual analysis files can be rendered by using rmarkdown::render()
or pressing the “Knit” button in RStudio. Doing this should:
data/
directory_analysis.Rmd
filedocs/
directoryThe clamour template assumes that you will be serving your website using GitHub pages but it should also be possible use other similar services (with minor modifications). Details on setting up GitHub pages are available here but briefly the steps are:
docs/
directorydocs/
directoryBy default your website will be available at a URL like https://GITHUB-USER.github.io/REPOSITORY. You can see what the example website looks like here.