|
发表于 2015-10-22 22:29:24
|
显示全部楼层
- > matrix(runif(16),nc=4) %>% as.matrix(.,dimnames=list(rep('',nrow(.)),rep('',ncol(.))))
- [,1] [,2] [,3] [,4]
- [1,] 0.7484581 0.1370888 0.7646024 0.34425065
- [2,] 0.1454710 0.6143530 0.9334903 0.07063345
- [3,] 0.2672157 0.6504680 0.6357481 0.33052649
- [4,] 0.9842165 0.4476431 0.6835570 0.18115859
- > m <- matrix(runif(16),nc=4)
- > rownames(m) <- rep('',dim(m)[1])
- > names(m) <- rep('',dim(m)[2])
- > m
- [,1] [,2] [,3] [,4]
- 0.60778037 0.83548941 0.59982837 0.3078928
- 0.48323877 0.27404860 0.01510861 0.1530069
- 0.20687539 0.41210451 0.74180909 0.3776251
- 0.04269461 0.05120398 0.89737020 0.4658878
- attr(,"names")
- [1] "" "" "" "" NA NA NA NA NA NA NA NA NA NA NA NA
- > colnames(m) <- rep('',dim(m)[2])
- > m
-
- 0.60778037 0.83548941 0.59982837 0.3078928
- 0.48323877 0.27404860 0.01510861 0.1530069
- 0.20687539 0.41210451 0.74180909 0.3776251
- 0.04269461 0.05120398 0.89737020 0.4658878
- attr(,"names")
- [1] "" "" "" "" NA NA NA NA NA NA NA NA NA NA NA NA
- > m <- matrix(runif(16),nc=4) %>% as.matrix(.,dimnames=list(rownames=rep('',nrow(.)),colnames=rep('',ncol(.))))
- > m
- [,1] [,2] [,3] [,4]
- [1,] 0.6300024 0.73849420 0.9306262 0.7582433
- [2,] 0.8353101 0.49880264 0.5067453 0.1094184
- [3,] 0.3225044 0.04808642 0.3209241 0.6930254
- [4,] 0.3411347 0.36887764 0.6131886 0.5393864
复制代码
这无名矩阵让咱想起多年前在COS认识的前辈兼高手 “无头衔站长”
{:soso_e114:} 尝试了一下 rownames() 和 colnames() 也行哦! |
|