简体   繁体   English

R 出错:使用 hclust() 调用国外 function 中的 NA/NaN/Inf

[英]Error in R: NA/NaN/Inf in foreign function call using hclust()

I'm trying to cluster MLB data by starting pitcher's name.我试图通过开始投手的名字来聚集 MLB 数据。 I've combed through the data I'm using and there is nothing with a value of na and I omitted them in the code below.我梳理了我正在使用的数据,没有任何值为 na 的数据,我在下面的代码中省略了它们。 Clustdata looks completely good to me ClustData preview but I get this error: Clustdata 对我来说看起来非常好ClustData 预览,但我收到此错误:

NAs introduced by coercionError in hclust(d, method = "single", members = clustdata[, 1]): NA/NaN/Inf in foreign function call (arg 7)由 hclust(d, method = "single", members = clustdata[, 1]) 中的 coercionError 引入的 NA:外国 function 调用中的 NA/NaN/Inf (arg 7)

I want to cluster that table by pitcher name by those attributes Anyone have any ideas?我想通过这些属性按投手名称对该表进行聚类有人有什么想法吗? Thanks!谢谢! I'm new to R我是 R 的新手

data7 = read.csv("GL2007.csv", header = T)

data8 = data.frame(na.omit(data7[c(10,23,24,25,26,30,31,33,105)]))
scoreagg = aggregate(v_score ~ h_starting_pitcher_name, data8, mean)
hitsagg = aggregate(v_hits ~ h_starting_pitcher_name, data8, mean)
doubagg = aggregate(v_doubles~ h_starting_pitcher_name, data8, mean)
tripagg = aggregate(v_triples~ h_starting_pitcher_name, data8, mean)
hragg = aggregate(v_homeruns ~ h_starting_pitcher_name, data8, mean)
hbpagg = aggregate(v_hit_by_pitch ~ h_starting_pitcher_name, data8, mean)
walksagg = aggregate(v_walks~ h_starting_pitcher_name, data8, mean)
SOagg = aggregate(v_strikeouts~ h_starting_pitcher_name, data8, mean)

clustdata = data.frame(scoreagg$h_starting_pitcher_name, scoreagg$v_score,hitsagg$v_hits,doubagg$v_doubles,tripagg$v_triples,hragg$v_homeruns,hbpagg$v_hit_by_pitch,walksagg$v_walks,SOagg$v_strikeouts)


library(NbClust)
d = dist(as.matrix(clustdata[,2:9]), method = "euclidean")
hc_1 = hclust(d, method = "single", members = clustdata[,1])

Since not a lot of details given in the question, it seems you are not using the members argument correctly.由于问题中没有提供很多细节,因此您似乎没有正确使用members参数。

Just leave it as NULL if your aim is only to obtain a clustering.如果您的目标只是获得聚类,请将其保留为 NULL。

hc_1 = hclust(d, method = "single")

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 pheatmap scale="row" 在 hclust(d, method = method) 中给出错误:外部函数调用中的 NA/NaN/Inf - pheatmap scale=“row” giving Error in hclust(d, method = method) : NA/NaN/Inf in foreign function call hclust(d,method = method)中的错误:外部函数调用(arg 11)中的NA / NaN / Inf - Error in hclust(d, method = method) : NA/NaN/Inf in foreign function call (arg 11) 如何修复以下“hclust 中的错误(d,方法 = hclustfun):外国 function 调用中的 NA/NaN/Inf(参数 11)” - How to fix the following “Error in hclust(d, method = hclustfun) : NA/NaN/Inf in foreign function call (arg 11)” hclust 错误(as.dist(1 - corr), method = hclust.method): NA/NaN/Inf in foreign function call (arg 10) — 但没有 NA/NaN/Inf 值 - Error in hclust(as.dist(1 - corr), method = hclust.method) : NA/NaN/Inf in foreign function call (arg 10) — but there's no NA/NaN/Inf values glmnet 中的 R 错误:外部函数调用中的 NA/NaN/Inf - R error in glmnet: NA/NaN/Inf in foreign function call R:vegdist的外部函数调用(arg 1)中的NA / NaN / Inf - R: NA/NaN/Inf in foreign function call (arg 1) for vegdist lme函数中的R错误:外部函数调用中的NA / NaN / Inf(arg 3) - R error in lme function: NA/NaN/Inf in foreign function call (arg 3) simpleLoess中的错误:外部函数调用中的NA / NaN / Inf - Error in simpleLoess: NA/NaN/Inf in foreign function call Montecarlo和Rstudio错误:外部函数调用中的NA / NaN / Inf(arg 5) - Montecarlo and rstudio error: NA/NaN/Inf in foreign function call (arg 5) glmer错误:外部函数调用(arg 1)中的NA / NaN / Inf - Error in glmer: NA/NaN/Inf in foreign function call (arg 1)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM