README.md

lefftpack::

A couple handfuls of utility functions for R that make my life easier.

Some are likely to be useful for any R user (esp. lazy_setup() and quiet_attach()). Others are more specific to the kind of work I do. Eventually there'll be a short vignette illustrating some of the more useful functions.

Also contains a few language-related datasets for experimenting with language/text analysis techniques.

Feedback welcome + appreciated!

-tim leffel

basic usage

To install the package:

devtools::install_github("lefft/lefftpack")

To load and attach the package (i.e. make all functions directly available in a session):

library("lefftpack")

Or you can use lefftpack:: to call just a single function without attaching the whole package, as in:

# e.g. to load and attach a handful of common packages + set a nice plot theme
lefftpack::lazy_setup()

# e.g. to quickly and quietly load and attach many packages:
lefftpack::quiet_attach("quanteda","tm","lme4","lmerTest", shhh="failonly")

nb. use lefftpack::lazy_setup(tim=FALSE) to exclude lefftpack:: from the default set of packages to attach.

bundled data

The package also contains three datasets, each in a different format. I find them useful for demonstrating/practicing/experimenting with various linguistic analysis and NLP techniques.

Here's some basic info about them (see documentation for more detail):

nb. The raw text datasets both have a fairly formal style, and are actually interestingly similar to one another linguistically (more than you might guess, and in certain specific ways, at least). This is the only reason they're included.

misc. notes

The name of the lazy_setup() function is meant to evoke "sloth", not "lazy evaluation" -- argument defaults are pre-set to attach a handful of useful packages (the ones I use most) and set a nice ggplot2:: theme. The default behavior of lazy_setup() produces the console message below:

# (to prevent console output, set `show_message=FALSE`)
lefftpack::lazy_setup()
>> these packages are now attached: 
     lefftpack reshape2 ggplot2 magrittr dplyr
>> custom `ggplot2::` plot theme is now set

You can also pass lazy_setup() a vector of (quoted) package names via the packages parameter, in which case it'll just attach the ones you give it.

lefftpack::lazy_setup(c("dplyr","quanteda","tm","ggplot2"))

To prevent all console messages, just set quiet=TRUE. Though note that you'll still get a warning if you've tried to attach a non-existent package -- imo that's better than the aggressive error library("blahh") would normally give you by default! :p)



lefft/lefftpack documentation built on May 8, 2019, 1:13 p.m.