generalize.hz {aqp} | R Documentation |
Generalize a vector of horizon names, based on new classes, and REGEX patterns.
generalize.hz(x, new, pat, non.matching.code)
x |
a character vector of horizon names |
new |
a character vector of new horizon classes |
pat |
a character vector of REGEX, same length as |
non.matching.code |
text used to describe any horizon not matching any item in |
factor of the same length as x
Dylan E. Beaudette
http://casoilresource.lawr.ucdavis.edu/
data(sp1)
# check original distribution of hz designations
table(sp1$name)
##
## 2C 2C1 2C2 3Ab 3Bwb 3C 3Cb A A1 A2 A3 AB AB1 AB2 AB3
## 2 2 2 1 2 2 1 4 4 4 1 5 1 1 1
## BA Bt Bt1 Bt2 Bw1 Bw2 Bw3 C C1 C2 Oa/A Oe Oi Rt
## 2 1 3 3 3 3 1 1 2 2 1 1 3 1
# generalize
sp1$genhz <- generalize.hz(sp1$name,
new=c('O','A','B','C','R'),
pat=c('O', '^A','^B','C','R'))
# see how we did / what we missed
table(sp1$genhz, sp1$name)
##
## 2C 2C1 2C2 3Ab 3Bwb 3C 3Cb A A1 A2 A3 AB AB1 AB2 AB3 BA Bt Bt1
## O 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## A 0 0 0 0 0 0 0 4 4 4 1 5 1 1 1 0 0 0
## B 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 1 3
## C 2 2 2 0 0 2 1 0 0 0 0 0 0 0 0 0 0 0
## R 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## not-used 0 0 0 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0
##
## Bt2 Bw1 Bw2 Bw3 C C1 C2 Oa/A Oe Oi Rt
## O 0 0 0 0 0 0 0 1 1 3 0
## A 0 0 0 0 0 0 0 0 0 0 0
## B 3 3 3 1 0 0 0 0 0 0 0
## C 0 0 0 0 1 2 2 0 0 0 0
## R 0 0 0 0 0 0 0 0 0 0 1
## not-used 0 0 0 0 0 0 0 0 0 0 0