Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

chunksAdd

Manage counts of text chunks


Description

Perl subroutines are used to add and delete chunks of text to tables of their counts.

Usage

chunksAdd(table, data, convert)

chunksDrop(table, data, convert)

Arguments

table

A proxy reference to a Perl hash containing counts, as returned from a previous call to chunksAdd() or chunksDrop(). On the initial call to chunksAdd() , this argument will be omitted, and initialized as an empty table.

data

A vector of items to be added or dropped from the counts in the table. Typically a character vector but any mix of scalar items can be supplied.

convert

Should the result be returned as a proxy reference to the table (a Perl hash), or converted to a named vector in R? By default, the table is converted if the data argument is omitted or of zero length.

Value

A proxy reference to a Perl hash, if convert is FALSE; otherwise a named vector (the conversion is done by the Perl interface in package RSPerl, and will be a named vector of counts.

Author(s)

John M. Chambers <jmc@r-project.org>

References

http://www.omegahat.net/RSPerl/ for the RSPerl interface.

Examples

## Not run: 
if(require(RSPerl)){
  set.seed(314)
  someLetters <- sample(letters, 100, TRUE)
  tbl <- chunksAdd(data = someLetters[1:50])
  tbl <- chunksAdd(tbl, someLetters[51:100])
  tbl <- chunksDrop(tbl, someLetters[1:10])
  chunksAdd(tbl) # to convert the table
}

## End(Not run)

SoDA

Functions and Examples for "Software for Data Analysis"

v1.0-6.1
GPL (>= 2)
Authors
John M Chambers
Initial release
2014-06-12

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.