colMedians(x) : Argument ‘x’ must be a matrixrowMedians(data) : Argument ‘x‘ must be a matrix.
Posted Data+Science+Insight
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了colMedians(x) : Argument ‘x’ must be a matrixrowMedians(data) : Argument ‘x‘ must be a matrix.相关的知识,希望对你有一定的参考价值。
colMedians(x) : Argument ‘x’ must be a matrix、rowMedians(data) : Argument 'x' must be a matrix.
目录
colMedians(x) : Argument ‘x’ must be a matrix、rowMedians(data) : Argument 'x' must be a matrix.
问题:
#仿真数据
set.seed(1234)
# Set seed
data <- data.frame(matrix(round(runif(12, 1, 20)),
# Create example data
nrow = 3, ncol = 4))
data
# Print data to RStudio console
# error
install.packages("robustbase")
# Install robustbase package
library("robustbase")
# Load robustbase package
colMedians(data)
# Error in colMedians
# Error in colMedians(data) : Argument 'x' must be a matrix
rowMedians(data)
# Error in rowMedians
# Error in rowMedians(data) : Argument 'x' must be a matrix.
解决:
data_mat <- as.matrix(data)
# Convert data.frame to matrix
colMedians(data_mat)
# No colMedians error anymore
# X1 X2 X3 X4
# 13 13 5 11
rowMedians(data_mat)
# No rowMedians error anymore
# 7.0 13.5 13.0
完整错误:
# Error in colMedians
# Error in colMedians(data) : Argument 'x' must be a matrix
# Error in rowMedians
# Error in rowMedians(data) : Argument 'x' must be a matrix.
参考:colSums, rowSums, colMeans & rowMeans in R | 5 Example Codes + Video
参考:statisticsglobe.com
参考:R
以上是关于colMedians(x) : Argument ‘x’ must be a matrixrowMedians(data) : Argument ‘x‘ must be a matrix.的主要内容,如果未能解决你的问题,请参考以下文章
Halo2 学习笔记——设计之Proving system之Multipoint opening argument
INVALID_ARGUMENT:断言失败:[预测必须是 <= 1] [条件 x <= y 没有按元素保持:]
Python:XXX missing X required positional argument: 'self'
Halo2 学习笔记——设计之Proving system之Vanishing argument
解决 TypeError: ('Keyword argument not understood:', 'padding')