#' Calculate the contribution of each data point to overall variance
#'
#' Calculate the contribution of each data point described by the x and y coordinates to the overall sample variance.
#'
#' @param x A vector specifying x coordinates of data points.
#' @param y A vector specifying y coordinates of data points. It is assumed that the order of coordinates is concordant with regards to data point.
#' @export
calcAlexDistance <- function(x,y){
combinedDistance <- vector()
distancePerX <- vector()
distancePerY <- vector()
xVarience <- var(x)
yVarience <- var(y)
for ( i in 1:length(x)){
instanceVarience <- var(x[-i])
instanceDistX <- abs(xVarience - instanceVarience)
distancePerX <- append(distancePerX,instanceDistX)
}
for ( i in 1:length(y)){
instanceVarience <- var(y[-i])
instanceDistY <- abs(yVarience - instanceVarience)
distancePerY <- append(distancePerY,instanceDistY)
}
combinedDistance <- distancePerY + distancePerX
return(list(distancePerY=distancePerY,distancePerX=distancePerX,combinedDistance=combinedDistance))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.