【问题标题】:length of 'center' must equal the number of columns of 'x'“中心”的长度必须等于“x”的列数
【发布时间】:2016-07-19 18:30:09
【问题描述】:

我正在尝试在 R 中缩放矩阵。 我有:

maxs<- apply(rawsingle,2,max)
mins<- apply(rawsingle,2,min)

然后

scaledss<- scale(rawsingle,center=mins,scale = (maxs-mins))

我得到错误:

'scale.default(rawsingle, center = mins, scale = (maxs - mins)) 中的错误:
“中心”的长度必须等于“x”的列数

出现错误后,我立即输入:

 length(mins)==ncol(rawsingle)

它返回了TRUE,所以我不知道发生了什么。

以前有没有人遇到过类似的问题?

【问题讨论】:

  • 请问dput rawsingle 数据框好吗?

标签: r machine-learning scaling


【解决方案1】:

所有变量都必须是numeric类型:

dades[2:13] &lt;- lapply(dades[2:13], as.numeric)

【讨论】:

    【解决方案2】:

    问题是 'rawsingle' 中的某些元素是字符串,因为加载时出错。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-07-19
      • 2019-07-24
      • 1970-01-01
      • 2019-08-22
      • 2019-03-03
      • 1970-01-01
      • 1970-01-01
      • 2019-09-26
      相关资源
      最近更新 更多