【发布时间】:2021-01-10 19:23:19
【问题描述】:
我正在尝试使用 R 包 clustMixType 中的 kproto() 函数对 Julia 中的混合类型数据进行聚类,但出现错误 No numeric variables in x! Try using kmodes() from package...。我的数据应该有 3 个变量:2 个连续变量和 1 个分类变量。似乎在我使用DataFrame() 之后,所有变量都变成了分类变量。有没有办法避免在使用DataFrame() 后更改变量类型,以便我有混合类型的数据(连续和分类)来使用kproto()?
using RCall
@rlibrary clustMixType
# group 1 variables
x1=rand(Normal(0,3),10)
x2=rand(Normal(1,2),10)
x3=["1","1","2","2","0","1","1","2","2","0"]
g1=hcat(x1,x2,x3)
# group 2 variables
y1=rand(Normal(0,4),10)
y2=rand(Normal(-1,6),10)
y3=["1","1","2","1","1","2","2","0","2","0"]
g2=hcat(y1,y2,y3)
#create the data
df0=vcat(g1,g2)
df1 = DataFrame(df0)
#use R function
R"kproto($df1, 2)"
【问题讨论】:
标签: dataframe julia cluster-analysis