Subsets various object types based on a given vector or grep partial matching of data names.

# S3 method for class 'rspec'
subset(x, subset, ...)

# S3 method for class 'colspace'
subset(x, subset, ...)

# S3 method for class 'vismodel'
subset(x, subset, ...)

Arguments

x

(required) an object of class rspec, vismodel, or colspace, containing spectra, visual model output or colourspace data to subset.

subset

a string used for partial matching of observations.

...

additional attributes passed to grep. Ignored if subset is logical.

Value

a subsetted object of the same class as the input object.

Note

if more than one value is given to subset, any spectra that matches either condition will be included. It's a union, not an intersect.

Author

Chad Eliason cme16@zips.uakron.edu

Examples

data(sicalis)
vis.sicalis <- vismodel(sicalis)
tcs.sicalis <- colspace(vis.sicalis, space = "tcs")

# Subset all 'crown' patches (C in file names)
head(subset(sicalis, "C"))
#>    wl    ind1.C    ind2.C     ind3.C    ind4.C    ind5.C     ind6.C    ind7.C
#> 1 300 0.7594984 0.2971167 0.05947619 0.3750159 0.4225349 0.06326984 0.1680730
#> 2 301 0.7727841 0.2326722 0.00000000 0.3465714 0.5361222 0.06136508 0.1043270
#> 3 302 0.8288000 0.3227833 0.11853968 0.4133333 0.6554556 0.01934921 0.1702476
#> 4 303 0.9414667 0.3535167 0.09427302 0.4339333 0.6816556 0.08594921 0.1939810
#> 5 304 1.0321333 0.4390214 0.21977778 0.3617143 0.7236937 0.08249206 0.2641048
#> 6 305 1.0845778 0.5022278 0.24920635 0.4820000 0.7076778 0.17968254 0.3900254
head(subset(sicalis, c("B", "C")))
#>    wl    ind1.C   ind1.B    ind2.C   ind2.B     ind3.C   ind3.B    ind4.C
#> 1 300 0.7594984 1.794473 0.2971167 1.404333 0.05947619 1.783476 0.3750159
#> 2 301 0.7727841 1.861124 0.2326722 1.432270 0.00000000 1.917762 0.3465714
#> 3 302 0.8288000 1.936600 0.3227833 1.640000 0.11853968 2.002000 0.4133333
#> 4 303 0.9414667 2.114267 0.3535167 1.801733 0.09427302 2.197067 0.4339333
#> 5 304 1.0321333 2.229314 0.4390214 1.977619 0.21977778 2.334286 0.3617143
#> 6 305 1.0845778 2.540378 0.5022278 2.108333 0.24920635 2.483333 0.4820000
#>      ind4.B    ind5.C   ind5.B     ind6.C   ind6.B    ind7.C    ind7.B
#> 1 0.5760159 0.4225349 2.357678 0.06326984 3.018032 0.1680730 0.7361429
#> 2 0.6230476 0.5361222 2.388440 0.06136508 3.242667 0.1043270 0.7706349
#> 3 0.7973333 0.6554556 2.464900 0.01934921 3.449667 0.1702476 0.9956667
#> 4 0.8617333 0.6816556 2.590300 0.08594921 3.703733 0.1939810 1.1890000
#> 5 1.0439048 0.7236937 2.827281 0.08249206 3.959571 0.2641048 1.3070476
#> 6 1.1046667 0.7076778 3.103233 0.17968254 4.258000 0.3900254 1.4298889
head(subset(sicalis, "T", invert = TRUE))
#>    wl    ind1.C   ind1.B    ind2.C   ind2.B     ind3.C   ind3.B    ind4.C
#> 1 300 0.7594984 1.794473 0.2971167 1.404333 0.05947619 1.783476 0.3750159
#> 2 301 0.7727841 1.861124 0.2326722 1.432270 0.00000000 1.917762 0.3465714
#> 3 302 0.8288000 1.936600 0.3227833 1.640000 0.11853968 2.002000 0.4133333
#> 4 303 0.9414667 2.114267 0.3535167 1.801733 0.09427302 2.197067 0.4339333
#> 5 304 1.0321333 2.229314 0.4390214 1.977619 0.21977778 2.334286 0.3617143
#> 6 305 1.0845778 2.540378 0.5022278 2.108333 0.24920635 2.483333 0.4820000
#>      ind4.B    ind5.C   ind5.B     ind6.C   ind6.B    ind7.C    ind7.B
#> 1 0.5760159 0.4225349 2.357678 0.06326984 3.018032 0.1680730 0.7361429
#> 2 0.6230476 0.5361222 2.388440 0.06136508 3.242667 0.1043270 0.7706349
#> 3 0.7973333 0.6554556 2.464900 0.01934921 3.449667 0.1702476 0.9956667
#> 4 0.8617333 0.6816556 2.590300 0.08594921 3.703733 0.1939810 1.1890000
#> 5 1.0439048 0.7236937 2.827281 0.08249206 3.959571 0.2641048 1.3070476
#> 6 1.1046667 0.7076778 3.103233 0.17968254 4.258000 0.3900254 1.4298889
subset(vis.sicalis, "C")
#>                 u          s         m         l lum
#> ind1.C 0.09841647 0.02988172 0.3894516 0.4822502  NA
#> ind2.C 0.10120471 0.02696028 0.3939779 0.4778571  NA
#> ind3.C 0.05186887 0.02865504 0.4133352 0.5061409  NA
#> ind4.C 0.05539667 0.02761281 0.4087808 0.5082097  NA
#> ind5.C 0.06248511 0.02346180 0.4160001 0.4980530  NA
#> ind6.C 0.06136284 0.05713308 0.4057493 0.4757548  NA
#> ind7.C 0.05558762 0.02643794 0.4109604 0.5070140  NA
subset(tcs.sicalis, "C")[, seq_len(5)]
#>                 u          s         m         l        u.r
#> ind1.C 0.09841647 0.02988172 0.3894516 0.4822502 -0.1515835
#> ind2.C 0.10120471 0.02696028 0.3939779 0.4778571 -0.1487953
#> ind3.C 0.05186887 0.02865504 0.4133352 0.5061409 -0.1981311
#> ind4.C 0.05539667 0.02761281 0.4087808 0.5082097 -0.1946033
#> ind5.C 0.06248511 0.02346180 0.4160001 0.4980530 -0.1875149
#> ind6.C 0.06136284 0.05713308 0.4057493 0.4757548 -0.1886372
#> ind7.C 0.05558762 0.02643794 0.4109604 0.5070140 -0.1944124