sim.measure.attributes-class | R Documentation |
Accessor and construction functions for dealing with the
sim.measure
attributes of similarity measures. The sim.measure.attributes
extracts or constructs an object showing the attributes, whereas sim_measure_function
extracts
the similarity function itself.
sim.measure.attributes(x, ...) sim_measure_function(x, ...) ## S4 method for signature 'sim.measure' sim.measure.attributes(x, ...) ## S4 method for signature 'sim.measure' sim_measure_function(x, ...) ## S4 method for signature 'character' sim.measure.attributes(x, type_measure, signed)
x |
An sim.measure |
... |
Ignored |
type_measure |
Character, the type of similarity measure which should be repesented |
signed |
Logical, is the similarity measure signed? |
string
Character, the similarity score's human readable name
type_measure
Character, what type to similarity measure is this (equvialent to type
field
in sim.measure)
signed
Logical, does this similarity measure return signed results?
# This measures how well the arguments agree with the signs # This primary function accept two vectors only my_measure_simple <- function(x,y){ (sum((x > 0) & (y > 0)) + sum((x < 0) & (y < 0))) / (sum(x > 0) + sum(x < 0)) } # We extend this function into acception a matrix argument when y is now supplied my_measure <- function(x,y=NULL){ if(is.null(y)){ n_vectors <- ncol(x) res <- matrix(NA_real_,n_vectors,n_vectors) for (i in seq_len(n_vectors)){ for(j in seq_len(n_vectors)){ res[i,j] <- my_measure_simple(x[,i],x[,j]) } } res } else{ my_measure_simple(x,y) } } my_sim_score <-sim.measure(my_measure,string= "My measure", categorical = FALSE, mean_scaleable = FALSE, signed = FALSE, type = "non-paramtric") sim_fun <- sim_measure_function(my_sim_score) sim_fun(c(1,0,-1),c(2,-1,-1)) sim.measure.attributes(my_sim_score)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.