【发布时间】:2015-05-30 17:02:37
【问题描述】:
我正在尝试创建一个可以查找摘要和行数的函数,所以首先我尝试创建如下内容:
G <- summary(mtcars)
H <- nrow(mtcars)
I <- ("# of Rows")
J <- (c(I,H))
K <- print(G,J)
K
我收到以下错误:
Error in format.default(unclass(x), digits = digits, justify = justify) :
invalid 'digits' argument
In addition: Warning message:
In format.default(unclass(x), digits = digits, justify = justify) :
NAs introduced by coercion
> K
Error: object 'K' not found
我想得到的是这样的:
V1
Min. : 19.35
1st Qu. : 61.22
Median : 126.76
Mean : 212.96
3rd Qu. : 158.13
Max. : 1500.00
# of Rows: 367
显然我已经离开这里,但我似乎无法让我的矩阵和向量一起工作。任何帮助表示赞赏!
【问题讨论】:
-
如果没有可重现的示例,您的问题实际上并不清楚。您是否希望该函数仅适用于一列 data.frames?
-
抱歉,添加示例。之前以为很清楚,显然是错的。谢谢
标签: r function matrix vector summary