Package 'clamour'

Title: Website for Twitter analysis results
Description: clamour provides a template for setting up a website to display the results of analysis of Twitter hashtags.
Authors: Luke Zappia [aut, cre]
Maintainer: Luke Zappia <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0
Built: 2024-09-10 02:53:35 UTC
Source: https://github.com/lazappi/clamour

Help Index


clamour list

Description

Produce a Markdown string with details of all the clamour analysis files in a directory. This function is primarily designed to be used in the index of a website so the list is automatically updated.

Usage

clamour_list(path = ".", ignore = c("index.Rmd", "about.Rmd", "_analysis.Rmd"))

Arguments

path

Path to directory to search for .Rmd files

ignore

Vector or files to ignore

Value

Markdown string describing analysis files


Load tweets

Description

Load tweets for a clamour analysis

Usage

clamour_load_tweets(
  query,
  cache_file = NULL,
  timezone = Sys.timezone(),
  fixed = FALSE
)

Arguments

query

Query string to use for collecting new tweets.

cache_file

Path to an .Rds file to store cached tweets.

timezone

Time zone associated with tweets.

fixed

If TRUE only read tweets from cache and do not download new tweets.

Details

If a cache file exists tweets will first be read from here. New tweets will also be downloaded if fixed = FALSE. Cached and new tweets are combined and only the most recent version of each tweet is kept. Additional datetime, date and hour fields are created using the supplied timezone.

Value

tibble containing tweets


New clamour analysis

Description

Creates a new analysis file based on the clamour template.

Usage

clamour_new(
  name,
  hashtag,
  description = paste("An analysis of", hashtag),
  start_day = Sys.Date(),
  end_day = Sys.Date() + 1,
  timezone = Sys.timezone(),
  theme = "theme_light",
  accent = "dodgerblue",
  accent2 = NULL,
  kcore = 2,
  topics_k = 6,
  bigram_filter = 3,
  fixed = FALSE,
  seed = 1,
  dir = "analysis"
)

Arguments

name

Name of the analysis. This is used to name files so should usually be short and simple.

hashtag

The hashtag to use for this analysis, starting with "#". Can also be a vector of hashtags.

description

A more detailed description of the analysis, details of the event etc.

start_day

First day to be included in the analysis.

end_day

Last day to be included in the analysis.

timezone

Timezone to be used for the analysis.

theme

Name of a ggplot2 theme function to use for plots.

accent

Accent colour to use for plots.

accent2

Secondary accent colour to use for plots. If NULL this will be created based on accent.

kcore

k-core to use for filtering the mentions network.

topics_k

Number of topics to use for topic modelling.

bigram_filter

Number of co-occurrences for filtering the bigram graph.

fixed

Whether to continue to search and download new tweets. Set to TRUE to fix the dataset used for analysis.

seed

Random seed set at the start of analysis.

dir

Directory to save the new analysis file.

Value

Path to the newly created file, invisibly


Setup a clamour project

Description

This function creates the directory structure necessary for analysing Twitter hashtag activity and displaying the results on a website. It will also prompt you to install packages required by the default analysis and to authorise rtweet.

Usage

clamour_setup(path, rstudio = rstudioapi::isAvailable(), open = interactive())

Arguments

path

A path for the project. If it exists it will be used. If it does exist it will be created, provided the parent path exists.

rstudio

If TRUE, calls usethis::use_rstudio() to make the new project into an RStudio Project. If FALSE a sentinel .here file is placed so that the directory can be recognized as a project by the here or rprojroot packages.

open

If TRUE, activates the new project:

  • If using RStudio desktop, the package is opened in a new session.

  • If on RStudio server, the current RStudio project is activated.

  • Otherwise, the working directory and active project is changed.

Value

Path to the newly created project, invisibly.

References

Based on usethis::create_package()


clamour table

Description

Read the YAML front matter from a set of clamour analysis files and produce a tidy data.frame.

Usage

clamour_table(
  path = ".",
  ignore = c("index.Rmd", "about.Rmd", "_analysis.Rmd")
)

Arguments

path

Path to directory to search for .Rmd files

ignore

Vector or files to ignore

Value

data.frame containing information on analysis files