“ kmeans中的错误(na.omit(reduced_data_numeric,5)):'中心'必须是数字或矩阵”尝试将RMD编织成HTML时的消息
试图编织RMD脚本时,我会出现一条错误消息。我试图从第363-364行的数据中删除任何NA,但这无效。这很烦人,因为K-均值已经运行,我能够使用一些简单的代码来绘制绘制,但是由于某种原因,它不会编织。这是有效的原始代码:
KM <- kmeans(reduced_data_numeric, 5)
这是我要使用的代码来编织它:
KM <- kmeans(na.omit(reduced_data_numeric, 5))
这是“输出”部分中显示的消息,试图渲染HTML编织:
Quitting from lines 363-364 (Movies-Analysis.Rmd)
Error in kmeans(na.omit(reduced_data_numeric, 5)) :
'centers' must be a number or a matrix
Calls: <Anonymous> ... withVisible -> eval_with_user_handlers -> eval -> eval -> kmeans
I am presented with an error message when trying to knit an Rmd script. I have tried to drop any NA's from the data being used for lines 363-364 but this did not work. It is annoying because the k-means has been run and I have been able to plot using some simple code, but for some reason it won't knit. This was the original code that worked:
KM <- kmeans(reduced_data_numeric, 5)
Here is the Code I am trying to use in order for it to knit:
KM <- kmeans(na.omit(reduced_data_numeric, 5))
Here is the message shown in 'output' section when trying to render the HTML knit:
Quitting from lines 363-364 (Movies-Analysis.Rmd)
Error in kmeans(na.omit(reduced_data_numeric, 5)) :
'centers' must be a number or a matrix
Calls: <Anonymous> ... withVisible -> eval_with_user_handlers -> eval -> eval -> kmeans
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您已将中心数作为
na.omit
而不是kmeans
的参数。请注意,括号在此行的末端以及5个位置的位置:
You've included the number of centers as an argument for
na.omit
rather thankmeans
.Note where the parenthesis are at the end of this line and where the 5 is: