enve.df2dist {enveomics.R} | R Documentation |
Enveomics: Data Frame to Dist
Description
Transform a dataframe (or coercible object, like a table) into a dist object.
Usage
enve.df2dist(
x,
obj1.index = 1,
obj2.index = 2,
dist.index = 3,
default.d = NA,
max.sim = 0
)
Arguments
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:
|
Value
Returns a dist object.
Author(s)
Luis M. Rodriguez-R [aut, cre]
Examples
# 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)
[Package enveomics.R version 1.9.1 Index]