For our experiments with stylometry, we will be using the stylo package for R developed by Maciej Eder, Jan Rybicki, and Mike Kestemont. This page is a cleaned-up version of their installation guidelines from the package’s home page as well as their “how-to.”
Things to install
Prep your corpus
- Create a working folder for the project you’re tackling (e.g., bom-stylo).
- Within that working folder, create a folder called “corpus” and place your texts in there. It will work best if the files are plain text.
- Make sure that each text is named with the feature that you’re testing for, followed by an underscore and then whatever you want. For example, authorname_title.txt or gender_title.txt.
In RStudio
- Install Stylo by typing
install.packages("stylo"). You’ll only need to do this once. Note the need for quotation marks. - Activate Stylo by typing
library(stylo). You’ll need to do this each time you start an RStudio session. - Move to your working folder (not the corpus folder) with the command
setwd(filepath). Alternatively, you can use RStudio’s menus:Session > Set Working Directory > Choose Directory... - Type
stylo()to start up the function with the GUI working. - Click
OKwhen you’ve got all the options set.
GUI options to tweak
Features
- Change MFW (most frequent word) count. Keep Minimum and Maximum set to identical values.
- Change Features from words to chars if wanted.
Statistics
- Cluster Analysis will produce a dendrogram.
- PCA (corr.) will produce a principal component analysis, which is easier to read.
Output
- Click “png” to save a copy of the outputted image file
- CPA flavour
- Classic will be a simple graph with just the label of the text.
- Loadings will provide the MFW superimposed along with the labels of the text.