【发布时间】:2021-07-05 15:24:20
【问题描述】:
我正在使用 R。我正在尝试在此处遵循以前的 stackoverflow 帖子中的代码:Kullback-Leibler distance between 2 samples
特别是,我试图确定两个数据集之间的“距离”:
#load library
library(FNN)
library(dplyr)
#create two data sets
df = iris
data1 = sample_n(df, 20)
data2 = sample_n(df, 20)
#plot KL divergence
plot(KLx.dist(data1,data2))
但是,这会产生以下错误:
Error in plot.window(...) : need finite 'ylim' values
In addition: Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf
有谁知道为什么会产生这个错误?
谢谢
【问题讨论】:
-
可能是因为 Species 列是非数字的?
-
谢谢!这解决了问题!你想发布这个答案吗?或者你想让我这样做(以便未来的读者可以弄清楚)。请让我知道 - 再次感谢!
标签: r