【发布时间】:2018-06-25 16:02:31
【问题描述】:
我想显示一个没有小的 [1,] 和 [,1] 行和列指示符的矩阵列表(不是单个矩阵,正如其他地方所询问的那样)。
例如,给定myList:
myList <- list(matrix(c(1,2,3,4,5,6), nrow = 2), matrix(c(1,2,3,4,5,6), nrow = 3))
names(myList) <- c("This is the first matrix:", "This is the second matrix:")
我正在寻找一些将输出的函数myFunction():
> myFunction(myList)
$`This is the first matrix:`
1 3 5
2 4 6
$`This is the second matrix:`
1 4
2 5
3 6
如果它可以消除列表名称周围的 $... 以便显示:
This is the first matrix:
1 3 5
2 4 6
This is the second matrix:
1 4
2 5
3 6
在阅读了所有相关问题后,我已经尝试过
myList %>% lapply(print, row.names = F)
myList %>% lapply(prmatrix, collab = NULL, rowlab = NULL)
myList %>% lapply(write.table, sep = " ", row.names = F, col.names = F)
但没有一个按预期工作。
【问题讨论】:
标签: r matrix lapply names write.table