gsr | R Documentation |
Performs in-place editing of data.frames that have factor columns while correcting for the change to levels.
gsr(field,old,new)
field |
a vector or specific column in a data.frame |
old |
a character vector of values to search for |
new |
a character vector of values to replace the respective items in old |
The function temporarily converts a vector or vector column in a data.frame to a character vector, and then loops through the ‘old’ vector looking for values to replace with the respective value in the ‘new’ vector. The column is then converted back to a factor.
a factor vector
The function is designed to make simple editing changes to data.frames or factor vectors, resetting the levels appropriately.
David W. Roberts droberts@montana.edu
data(brycesite)
brycesite$quad <- gsr(brycesite$quad,
old=c('bp','bc','pc','rp','tc','tr'),
new=c('BP','BC','PC','RP','TC','TR'))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.