README.md

OpinionReport

OpinionReport is an R package that includes utility to plot AbridgeNews reaction data.

Getting started

Install XQuartz

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/.

Install OpinionReport

In R or RStudio, install the OpinionReport R package from github.

Install and load devtools

install.packages( c('devtools'))
library(devtools)

Install and load OpinionReport

devtools::install_github('lhenneman/OpinionReport')
library(OpinionReport)

Define the data

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

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

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.

Topic title (file name)

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.

Output directory

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 = '.')

Make the plot

The plotting command (OpRep) requires five inputs.

1. The plot title

What do you want the main heading of the plot to be? Below, title is defined as 'Should UNCE Keep Silent Sam?'.

2. The directory that stores the data

OpRep looks in this directory (directory.in) for the input data file (it's looking for a file like the output from OpData).

3. The pattern that matches the name of the file

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.

4. The pattern that matches the name of the file

The saving location of the plot file.

5. Color bounds

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

Make the plots.

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")


lhenneman/OpinionReport documentation built on June 8, 2019, 5:59 a.m.