enve.df2dist | R Documentation |
Transform a dataframe (or coercible object, like a table) into a dist object.
enve.df2dist( x, obj1.index = 1, obj2.index = 2, dist.index = 3, default.d = NA, max.sim = 0 )
x |
A dataframe (or coercible object) with at least three columns:
|
obj1.index |
Index of the column containing the ID of the object 1. |
obj2.index |
Index of the column containing the ID of the object 2. |
dist.index |
Index of the column containing the distance. |
default.d |
Default value (for missing values). |
max.sim |
If not zero, assumes that the values are similarity (not distance) and this is the maximum similarity (corresponding to distance 0). Applies transformation: distance = (max.sim - values)/max.sim. |
Returns a dist object.
Luis M. Rodriguez-R [aut, cre]
# A sparse matrix representation of similarities as data frame. # The column "extra_data" is meaningless, only included to illustrate # the use of the obj*.index parameters sim <- data.frame( extra_data = c(0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.5), query = c("A", "A", "A", "B", "C", "C", "D"), subject = c("A", "B", "C", "B", "C", "B", "A"), similarity = c(100, 90, 60, 100, 100, 70, 10) ) dist <- enve.df2dist(sim, "query", "subject", "similarity", max.sim = 100) print(dist)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.