knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "README-" )
Built on the quanteda package for text analysis, LIWCalikes provides a simple interface to the analysis of text by counting words and other textual features, including the application of a dictionary to produce a tabular report of percentages. This provides similar functionality to the LIWC stand-alone software.
The user must supply a dictionary, which can include one of the custom LIWC dictionaries if these have been purchased from http://liwc.wpengine.com, or any other dictionary supplied by the user. The dictionary()
constructor of the quanteda package, on which LIWCalike is built, can read both LIWC and Wordstat-formatted dictionary files, or you can use it to create a dictionary from an R list object (a named list of character vectors, where each character vector is a set of dictionary match patterns and its associated name is the dictionary key).
This package is designed for R users and those wishing to build functionality by extending the quanteda package for text analysis. If you prefer to have a complete, stand-alone user interface, then you should purchase and use the LIWC standalone software. This has several advantages:
LIWC allows direct importing of files, including binary (Word, pdf, etc) formats. To use
LIWCalike, you will need to import these into the quanteda package first.
LIWCalike also works fine with simple character vectors, if you prefer to use
standard R methods to create your input object (e.g. readLines()
, read.csv()
, etc.)
LIWC provides direct outputs in the form of csv, Excel files, etc. By contrast, LIWCalike returns a data.frame
, which you have to export yourself (e.g. using write.csv()
.)
LIWC provides easy segmentation, through a GUI. By contrast, with LIWCalike you will
have to segment the texts yourself. (quanteda provides easy ways to do this using
segment()
and changeunits()
.)
LIWC color codes the dictionary value matches in your texts and displays these in a nice graphical window.
LIWC provides four composite measures that are not included in LIWCalike: "Analytic", "Clout", "Authentic", and "Tone". These are based on proprietary algorithms, as described and refernced in Pennebaker, J.W., Boyd, R.L., Jordan, K., & Blackburn, K. (2015). The development and psychometric properties of LIWC2015. Austin, TX: University of Texas at Austin. D OI: 10.15781/T29G6Z.
No dictionaries are supplied with LIWCalike, it is up to you to supply these. With the quanteda functions for creating or importing dictionaries, however, this is quite easy.
With the LIWC 2007, external dictionaries were distributed with the software that could be used in the format read by Provalis Research's Wordstat. Because I purchases a license for this product, I have that file and can use it with LIWCalike.
Using it is quite straightforward:
library("LIWCalike") library("quanteda") # read in the dictionary liwc2007dict <- dictionary(file = "~/Dropbox/QUANTESS/dictionaries/LIWC/LIWC2007.cat", format = "wordstat") tail(liwc2007dict, 1) # our test data data_char_testphrases # call LIWCalike output <- liwcalike(data_char_testphrases, liwc2007dict) # view some results output[, c(1:7, ncol(output)-2)]
LIWCalike is currently only available on GitHub, not on CRAN. The best method of installing it is through the devtools package:
devtools::install_github("kbenoit/LIWCalike")
This will also automatically install the quanteda package on which LIWCalike is built.
I welcome your comments and feedback. Please file issues on the issues page, and/or send me comments at kbenoit@lse.ac.uk.
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.