Pick a subsample form a spectra collection
subsample(x, ...) # S3 method for collection subsample(x, size = 2, balance_labels = FALSE, ids = NULL, ...)
x | A |
---|---|
... | further arguments passed to or from other methods(not currenctly used). |
size | Size of the sub-sampling |
balance_labels | A boolean, wether to pick spectra equally between labels. If the subsampling size is below the number of labels, not all labels will be chosen from. |
ids | A vector of ids to extract, this will override the other parameters. |
a subsample of x
#> Spectra collection containing 3 entries. #> Number of bins: 2250 #> Limits: -2.123166e-05 8.999979 #> Labels: conventional organic #> #> Processing:# Sample one spectra for each labels subsample(fa_nmr, size= 2, balance_labels = TRUE)#> Spectra collection containing 2 entries. #> Number of bins: 2250 #> Limits: -2.123166e-05 8.999979 #> Labels: conventional organic #> #> Processing:#> Spectra collection containing 3 entries. #> Number of bins: 2250 #> Limits: -2.123166e-05 8.999979 #> Labels: conventional organic #> #> Processing:# Sample alll spectra of specific labels organic <- fa_nmr$labels %>% filter(label == 'organic') %>% pull(id) subsample(fa_nmr, ids = organic)#> Spectra collection containing 3 entries. #> Number of bins: 2250 #> Limits: -2.123166e-05 8.999979 #> Labels: conventional organic #> #> Processing:# Chain subsamplings to randomly select a spectra with a specific label subsample(fa_nmr, ids = organic) %>% subsample(size=1)#> Spectra collection containing 1 entries. #> Number of bins: 2250 #> Limits: -2.123166e-05 8.999979 #> Labels: conventional organic #> #> Processing: