“ kmeans中的错误(na.omit(reduced_data_numeric,5)):'中心'必须是数字或矩阵”尝试将RMD编织成HTML时的消息

发布于 2025-02-08 20:19:31 字数 590 浏览 2 评论 0原文

试图编织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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦断已成空 2025-02-15 20:19:31

您已将中心数作为na.omit而不是kmeans的参数。

请注意,括号在此行的末端以及5个位置的位置:

KM <- kmeans(na.omit(reduced_data_numeric), 5)

You've included the number of centers as an argument for na.omit rather than kmeans.

Note where the parenthesis are at the end of this line and where the 5 is:

KM <- kmeans(na.omit(reduced_data_numeric), 5)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文