Last data update: 2014.03.03

R: Function to interpolate classes.
interpolate.classesR Documentation

Function to interpolate classes.

Description

This function interpolates grain-size classes, either to higher or to lower resolution.

Usage

interpolate.classes(X, boundaries.in, boundaries.out, method = "natural",
  fixed.start = TRUE)

Arguments

X

Numeric matrix with m samples (rows) and n variables (columns).

boundaries.in

Numeric vector with class boundaries of the input data.

boundaries.out

Numeric vector with class boundaries of the output data.

method

Logical scalar, interpolation method, one out of "linear" (linear interpolation), "fmm" (cubic spline), "natural" (natural spline), "periodic" (periodic spline). Default is "natural".

fixed.start

Logical scalar, specifying if the outer boundaries should be set to the same values as in the original matrix, default is TRUE. This may become necessary to avoid interpolation errors, see example.

Value

Numeric matrix with interpolated class values.

Author(s)

Michael Dietze, Elisabeth Dietze

References

Dietze E, Hartmann K, Diekmann B, IJmker J, Lehmkuhl F, Opitz S, Stauch G, Wuennemann B, Borchers A. 2012. An end-member algorithm for deciphering modern detrital processes from lake sediments of Lake Donggi Cona, NE Tibetan Plateau, China. Sedimentary Geology 243-244: 169-180.

See Also

EMMA, approx, spline

Examples

## load example data
data(X, envir = environment())
classes.in <- seq(from = 1, to = 10, length.out = ncol(X))

## Example 1 - decrease the class numbers
## define number of output classes
classes.out <- seq(1, 10, length.out = 20)

## interpolate the data set
Y <- interpolate.classes(X = X,
                         boundaries.in = classes.in,
                         boundaries.out = classes.out,
                         method = "linear")

## show original vs. interpolation for first 10 samples
plot(NA, xlim = c(1, 10), ylim = c(0, 11))
for(i in 1:10) {
  lines(classes.in, X[i,] * 20 + i)
  lines(classes.out, Y[i,] * 20 + i, col = 2)
}

## Example 2 - increase the class numbers
## define number of output classes
classes.out <- seq(1, 10, length.out = 200)

## interpolate the data set
Y <- interpolate.classes(X = X,
                         boundaries.in = classes.in,
                         boundaries.out = classes.out)

## show original vs. interpolation for first 10 samples
plot(NA, xlim = c(1, 10), ylim = c(0, 11))
for(i in 1:10) {
  lines(classes.in, X[i,] * 20 + i)
  lines(classes.out, Y[i,] * 20 + i, col = 2)
}

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(EMMAgeo)
Loading required package: GPArotation
Loading required package: limSolve
Loading required package: shape
Loading required package: shiny
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/EMMAgeo/interpolate.classes.Rd_%03d_medium.png", width=480, height=480)
> ### Name: interpolate.classes
> ### Title: Function to interpolate classes.
> ### Aliases: interpolate.classes
> ### Keywords: EMMA
> 
> ### ** Examples
> 
> ## load example data
> data(X, envir = environment())
> classes.in <- seq(from = 1, to = 10, length.out = ncol(X))
> 
> ## Example 1 - decrease the class numbers
> ## define number of output classes
> classes.out <- seq(1, 10, length.out = 20)
> 
> ## interpolate the data set
> Y <- interpolate.classes(X = X,
+                          boundaries.in = classes.in,
+                          boundaries.out = classes.out,
+                          method = "linear")
> 
> ## show original vs. interpolation for first 10 samples
> plot(NA, xlim = c(1, 10), ylim = c(0, 11))
> for(i in 1:10) {
+   lines(classes.in, X[i,] * 20 + i)
+   lines(classes.out, Y[i,] * 20 + i, col = 2)
+ }
> 
> ## Example 2 - increase the class numbers
> ## define number of output classes
> classes.out <- seq(1, 10, length.out = 200)
> 
> ## interpolate the data set
> Y <- interpolate.classes(X = X,
+                          boundaries.in = classes.in,
+                          boundaries.out = classes.out)
> 
> ## show original vs. interpolation for first 10 samples
> plot(NA, xlim = c(1, 10), ylim = c(0, 11))
> for(i in 1:10) {
+   lines(classes.in, X[i,] * 20 + i)
+   lines(classes.out, Y[i,] * 20 + i, col = 2)
+ }
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>