Previous: Examples Up: Examples Next: R Function Reference

Estimating Blogger Sentiment Toward Senator Hillary Clinton

This example uses a training set of size 500 to estimate sentiment toward Senator Hillary Rodham Clinton in a test set of size 1438 blog posts.

A control file is given in comma-separated form, along with the 1938 posts comprising the training and test sets. These can be found in demofiles/clintonposts within the package's install directory.

The command demo(clinton) executes the following R code:

oldwd <- getwd()
setwd(system.file("demofiles/clintonposts", package="ReadMe"))

undergrad.results <- undergrad(sep = ',')

undergrad.preprocess <- preprocess(undergrad.results)

readme.results <- readme(undergrad.preprocess)
setwd(oldwd)

The first two lines save the current working directory for the user's convenience, then switch the working directory to ``demofiles/clintonposts'' in the ReadMe directory.

The next line calls the ``undergrad'' function to process the texts based on the control file, storing the data in undergrad.results; default parameters are used, except that we specify that the control file is comma-separated with the ``sep'' argument.

Next, we use the ``preprocess'' function to remove columns with variance 0.

Finally, we store the results of the readme function in readme.results and restore the initial working directory.

After the demo is complete, its results can be viewed in readme.results and the intermediate data in undergrad.results and undergrad.preprocess.



Gary King 2011-03-02