The suite of stylometric tools, so far in the form of separate scripts, has been recently ported to a regular R package. Once installed, it provides a number of functions that can be invoked from inside the R console.
1. InstallationThere are two ways of installing "stylo": (1) from CRAN repository, (2) from a locally downloaded file 1.1. Installing from CRAN:
1.2. NOTE (Mac OS users): the package "stylo" requires X11 support being installed. To quote "R for Mac OS X FAQ" (http://cran.r-project.org/bin/macosx/RMacOSX-FAQ.html): "Each binary distribution of R available through CRAN is build to use the X11 implementation of Tcl/Tk. Of course a X windows server has to be started first: this should happen automatically on OS X, provided it has been installed (it needs a separate install on Mountain Lion or later). The first time things are done in the X server there can be a long delay whilst a font cache is constructed; starting the server can take several seconds." The newest versions of R (>3.1.0) seem to have Tcl/Tk support out-of-the-box, though. ANOTHER NOTE: When you install a recent version of R on OS X (e.g. Mavericks), you might run into encoding errors when you start up R (e.g. "WARNING: You're using a non-UTF8 locale" etc.). In that case, you should close R, open a new window in Applications > Terminal and execute the following line: defaults write org.R-project.R force.LANG en_US.UTF-8 Next, close the Terminal and start up R again. 1.3. Installing from a local file:
1.4. NOTE: the "stylo" package requires a few standard R packages to be
installed. When installing from CRAN, the dependencies are downloaded automatically; otherwise, you have to install them manually. Type (or copy-paste) the
following lines: install.packages("tcltk2") install.packages("ape") install.packages("class") install.packages("e1071") install.packages("pamr") install.packages("tsne") 2. Usage2.1. launch R;2.2. activate the package (whenever you start a fresh R session): library(stylo) this activates all functions of the package, including those for the major methods: stylo(), classify(), rolling.delta(), rolling.classify(), oppose(). 2.3. assuming that the working directory contains some corpora, try:
Additionally, the package in ver. >0.6.1 comes with three datasets:
Type help(galbraith) etc. to see what they contain. 3. Documentation and help3.1. A manual to stylometry using "stylo" is available here. help(load.corpus) help(stylo) etc. 3.3. a pdf version of the (automatically generated) manual is available here. 3.4. help pages routinely contain some examples: refer to them if you want to understand what a particular function does. They are ready to be copy-pasted to an active R console. 4. Advanced4.1. Some users might be interested in using the "stylo" library in batch mode, or to be able to pass any options directly to the function stylo() and/or classify() from the command-line. To exemplify: if you want to prepare a number of plots quickly, you do not need to use the GUI. Instead, just type:stylo(gui = F, mfw.min = 1000, mfw.max = 5000) 4.2. The biggest advantage of this approach is that the stylo() function can be embedded in a tailored script, written either in R and launched from inside R, or in any other scripting language. For instance, it can be invoked by cron on a Unix server, if one has to perform 1M computations, and the server resources are available on weekends and holidays. 4.3. More examples: see the manual here, section 9.
|


