Description Usage Arguments Value Author(s) See Also Examples
Random Samples and Permutations Take a sample of the specified size from the elements of x with or without replacement.
isample returns an vector of indices, sample returns the
corresponding hyperSpec object.
1 2 3 4 5 6 7 8 9 10 11 12 13 | ## S4 method for signature 'hyperSpec'
sample(x, size = nrow(x), replace = FALSE,
prob = NULL)
isample(x, size = nrow(x), replace = FALSE, prob = NULL)
## S4 method for signature 'data.frame'
sample(x, size = nrow(x), replace = FALSE,
prob = NULL, drop = FALSE)
## S4 method for signature 'matrix'
sample(x, size = nrow(x), replace = FALSE, prob = NULL,
drop = FALSE)
|
x |
The hyperSpec object, data.frame or matrix to sample fromto sample from |
size |
positive integer giving the number of spectra (rows) to choose. |
replace |
Should sampling be with replacement? |
prob |
A vector of probability weights for obtaining the elements of the vector being sampled. |
drop |
see |
a hyperSpec object, data.frame or matrix with size rows for sample, and an
integer vector for isample that is suitable for indexing (into the spectra) of x.
vector with indices suitable for row-indexing x
C. Beleites
1 2 3 4 5 6 7 8 9 10 11 12 13 | sample (flu, 3)
plot (flu, col = "darkgray")
plot (sample (flu, 3), col = "red", add = TRUE)
plot (flu, col = "darkgray")
plot (sample (flu, 3, replace = TRUE), col = "#0000FF80", add = TRUE,
lines.args = list (lwd = 2));
isample (flu, 3)
isample (flu, 3, replace = TRUE)
isample (flu, 8, replace = TRUE)
sample (cars, 2)
sample (matrix (1:24, 6), 2)
|
Loading required package: lattice
Loading required package: grid
Loading required package: ggplot2
Package hyperSpec, version 0.99-20180627
To get started, try
vignette ("hyperspec")
package?hyperSpec
vignette (package = "hyperSpec")
If you use this package please cite it appropriately.
citation("hyperSpec")
will give you the correct reference.
The project homepage is http://hyperspec.r-forge.r-project.org
hyperSpec object
3 spectra
3 data columns
181 data points / spectrum
wavelength: lambda/nm [numeric] 405.0 405.5 ... 495
data: (3 rows x 3 columns)
1. spc: I[fl]/"a.u." [matrix181] 66.80133 93.14433 ... 195.8673
2. filename: filename [character] rawdata/flu2.txt rawdata/flu3.txt rawdata/flu4.txt
3. c: c / (mg / l) [numeric] 0.10 0.15 0.20
[1] 6 1 4
[1] 3 5 4
[1] 3 5 3 3 2 1 3 5
speed dist
16 13 26
8 10 26
[,1] [,2] [,3] [,4]
[1,] 4 10 16 22
[2,] 6 12 18 24
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.