Description Usage Arguments Details Value Examples
Apply function for data underlying disto object
1 |
x |
disto object |
margin |
(one among 1 or 2) dimension to apply function along |
fun |
Function to apply over the margin |
subset |
(integer vector) Row/Column numbers along the margin. If this is missing, all rows or columns are considered |
nproc |
Number of parallel processes (unix only) |
progress |
(flag) Whether to show the progress bar or not. If missing and if the length of the subset is at least 1e4, progress is considered to be TRUE. |
fun should accept two arguments(in the same order): First, a vector of distances (row or column of a disto depending on the margin). Second, the row or the column number. See the example below
A list
1 2 3 4 5 6 7 8 9 10 11 12 | temp <- dist(iris[,1:4])
dio <- disto(objectname = "temp")
# function to pick unsorted indexes of 5 nearest neighbors (excepting itself)
udf_nn <- function(distances, index){
nnPlusOne <- which(
data.table::frankv(distances, ties.method = "dense") <= 6)
setdiff(nnPlusOne, index)
}
hi <- dapply(dio, 1, udf_nn)
head(hi)
max(sapply(hi, length))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.