OpinionReport
OpinionReport
is an R package that includes utility to plot AbridgeNews reaction data.
OpinionReport
relies on emoji fonts that have been tested on Mac and require an updated version of XQuartz. This can be downloaded and installed here: https://www.xquartz.org/.
OpinionReport
In R or RStudio, install the OpinionReport
R package from github.
devtools
install.packages( c('devtools'))
library(devtools)
OpinionReport
devtools::install_github('lhenneman/OpinionReport')
library(OpinionReport)
OpinionReport
includes a utility, OpData
that takes as inputs all the relavent information for a topic and saves a .csv file that can later be imported to the plotting function. The information is defined as follows:
Opinion data must be provided for the Left Side (LS), mid Left Side (mLS), mid Right Side (mRS), and Right Side (RS). OpinionData for each article should be provided as a named vector with three entries, "Agree", "Disagree", and "Undecided".
Names (LSname
, mLSname
, etc.) should be provided as text strings, but do not need to be provided if you prefer the column labels to be left blank (e.g., mLS
and mRS
are often left blank). If you want to have line breaks included in the eventual plot, use "/n
". In the command below, the Left Side name (LSname
) is provided with line break between "Remove" and "Silent", the Right Side name (RSname
) is provided with line break between "Keep" and "Silent", and no names are provided for mLSname
or mRSname
.
The topictitle
describes the day's topic in a short unique phrase without spaces that will be used as a base file name for both the .csv file and the eventual plot.
outdir
points to the saving location of the .csv file.
OpData( LSname = 'Remove\nSilent Sam',
RSname = 'Keep\nSilent Sam',
LSopinion = c( 'Agree' = 28,
'Disagree' = 12,
'Undecided' = 6 ),
mLSopinion = c( 'Agree' = 21,
'Disagree' = 13,
'Undecided' = 10 ),
mRSopinion = c( 'Agree' = 20,
'Disagree' = 11,
'Undecided' = 14 ),
RSopinion = c( 'Agree' = 19,
'Disagree' = 25,
'Undecided' = 6 ),
title = 'silentsam',
outdir = '.')
The plotting command (OpRep
) requires five inputs.
What do you want the main heading of the plot to be? Below, title
is defined as 'Should UNCE Keep Silent Sam?'.
OpRep
looks in this directory (directory.in
) for the input data file (it's looking for a file like the output from OpData
).
OpData
saves the .csv file with the title
pasted alongside the date the file was created. For example, a file created on 17 April, 2018 with title = 'silentsam'
would be called "silentsam2018-04-17.csv". Opdata
uses regex matching to look for the pattern.in
in file names within directory.in
for the file on which to base the plot. Your best bet is the use the same string for pattern.in
as you did for title
in OpData
.
The saving location of the plot file.
The colorbounds
describe the left and right colors on the topic's spectrum. Here are some examples.
political.colbounds <- c("#1028C7", "#E8273A")
unc.colbounds <- c("#4f9ccf", "#162e4e")
colbounds <- unc.colbounds
First, make a single plot that includes all four op-eds
OpRep( title = 'Should UNC Keep Silent Sam?',
directory.in = '.',
pattern.in = 'silentsam',
directory.out = '.',
text.colorbounds = colbounds)
Next, make individual plots for each op-ed
OpRep( title = 'Should UNC Keep Silent Sam?',
directory.in = '.',
pattern.in = 'silentsam',
directory.out = '.',
text.colorbounds = colbounds,
plottype = "4horizontal")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.