getCoords
get-coords.Rmd
Overview
This vignette describes the usage of the getCoords
parameter in the pandemonium
app.
This is an input for a named list of functions that can be used to calculate coordinates. The names of the list will be used as options for the coordinates selector in the GUI.
coordinates are a way to put each variable on equal footing for distance calculations. One simple coordinate function is normalising each variable by subtracting the mean and dividing by the standard deviation. Other forms are also possible and so we allow for the user to select what functions to pass to the app and which to use in the app.
Provided coordinate functions
Writing getCoords
functions
Inputs
Input | Description |
---|---|
df |
Data frame of raw values |
cov |
Covariance matrix of data frame |
covinv |
Inverse covariance matrix of data frame |
exp |
reference point |
Ouput
The function should return a single array the same size of the input df and with the same column names as df.
Example
pullCoordsNoCov <- function(df, cov, exp, ...){
n <- nrow(df)
df <- as.matrix(df)
nc <- ncol(df)
coord_mat <- matrix(nrow = n, ncol = nc)
for (i in 1:n){
for (j in 1:nc){
coord_mat[i, j] <- as.numeric((df[i, j] - exp$value[j]) / sqrt(cov[j, j]))
}
}
colnames(coord_mat) <- colnames(df)
return(coord_mat)
}
pandemonium(df,getCoords = list(pull = pullCoordsNoCov, normal = normCoords))