.getDistMat | R Documentation |
This function gets the euclidean (by default) distances between all points in a 2-D coordinate
system (x,y) to a group of points that fall on a fitted loess curve. It uses the dist.matrix
function from the wordspace
package.It is used in the selVarGenes
function.
.getDistMat(
loessModel = NULL,
x = NULL,
y = NULL,
x_curve = NULL,
method = "euclidean",
...
)
loessModel |
the loess fit to all points. |
x |
the x values of all points. |
y |
the y values of all points. |
x_curve |
the x values of the points on the loess curve. |
method |
distance measure to be used. |
... |
additional parameters for the |
An object of class matrix
and dist.matrix
, containing the
distances between all points to the specified points on the loess curve.
Dania Machlab
library(stats)
# create data
x <- 1:1000
y <- sort(rnorm(n = 1000, mean = 0, sd = 5)) + runif(n = 1000, min = 0, max = 10)
lo <- loess(y ~ x)
x_curve <- seq(range(x)[1], range(x)[2], length.out = 100)
# plot
plot(x, y, pch = 16, col = "#BEBEBE90")
lines(x_curve, predict(lo, newdata = x_curve), col = "red")
# get euclidean distance of all points to the curve (red)
euclMat <- swissknife:::.getDistMat(loessModel = lo, x = x, y = y, x_curve = x_curve)
euclMat[1:6, 1:6]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.