SomersDelta:as.table.default(x)中出错:无法强制为R中的tabl
数据示例SomersDelta:as.table.default(x)中出错:无法强制为R中的tabl,r,dplyr,R,Dplyr,数据示例 sommer=structure(list(tub = c(1L, 2L, 0L, 2L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 2L, 1L, 0L, 0L, 1L, 0L, 2L, 1L, 1L, 0L, 0L, 1L, 0L, 0L, 2L, 0L, 1L, 1L, 0L, 0L, 1L, 0L, 0L, 0L, 3L, 0L, 1L, 1L, 1L, 1L, 0L, 1L, 0L, 1L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 1L,
sommer=structure(list(tub = c(1L, 2L, 0L, 2L, 0L, 0L, 0L, 0L, 0L,
1L, 1L, 2L, 1L, 0L, 0L, 1L, 0L, 2L, 1L, 1L, 0L, 0L, 1L, 0L, 0L,
2L, 0L, 1L, 1L, 0L, 0L, 1L, 0L, 0L, 0L, 3L, 0L, 1L, 1L, 1L, 1L,
0L, 1L, 0L, 1L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 1L, 1L, 0L, 1L, 3L,
2L, 0L, 1L, 0L, 3L, 2L, 2L, 0L, 0L, 0L, 1L, 0L, 0L, 3L, 1L, 1L,
3L, 1L), fq = c(1L, 1L, 0L, 1L, 0L, 0L, 0L, 0L,
0L, 1L, 3L, 6L, 1L, 0L, 0L, 1L, 0L, 2L, 4L, 2L, 0L, 0L, 2L, 0L,
0L, 5L, 0L, 1L, 2L, 0L, 0L, 1L, 0L, 0L, 0L, 14L, 0L, 1L, 1L,
1L, 4L, 0L, 1L, 0L, 4L, 0L, 0L, 0L, 6L, 1L, 0L, 0L, 1L, 1L, 0L,
1L, 3L, 4L, 0L, 1L, 0L, 8L, 1L, 2L, 0L, 0L, 0L, 2L, 0L, 0L, 3L,
2L, 2L, 1L, 1L)), .Names = c("tub", "fq"), class = "data.frame", row.names = c(NA,
-75L))
我想计算一下三角洲
library("DescTools")
SomersDelta(sommer, direction = c("row", "column"))
我得到了错误
Error in as.table.default(x) : cannot coerce to a table
Error in margin.table(tab, 1) : 'x' is not an array
我还想得到脊椎图
library("coin")
spineplot(sommer)
但是我得到了错误
Error in as.table.default(x) : cannot coerce to a table
Error in margin.table(tab, 1) : 'x' is not an array
有两个错误吗?
如何计算SomersDelta并得到这样的脊椎图
它需要一个
矩阵作为输入。根据?SomersDelta
x-数字向量或表格。矩阵将被视为表
这里,数据集是一个data.frame
类。我们可以将其转换为matrix
(as.matrix
),它应该可以正常工作
SomersDelta(as.matrix(sommer), direction = c("row", "column"))
#[1] -0.06137931
它需要一个矩阵
作为输入。根据?SomersDelta
x-数字向量或表格。矩阵将被视为表
这里,数据集是一个data.frame
类。我们可以将其转换为matrix
(as.matrix
),它应该可以正常工作
SomersDelta(as.matrix(sommer), direction = c("row", "column"))
#[1] -0.06137931
,谢谢,你能帮我得到想要的脊椎图吗?@Kogan对于脊椎
图,你需要拖船
vsfq
@Kogan你需要库(dplyr);图书馆(tidyr);聚集(sommer)%%>%mutate_all(factor)%%>%spineplot(value~key,data=)
,谢谢,你能帮我得到想要的脊椎图吗?@Kogan对于脊椎
图,你需要tug
vsfq
@Kogan你需要库(dplyr);图书馆(tidyr);聚集(sommer)%%>%mutate_all(factor)%%>%spineplot(value~key,data=)