r - 为什么 noquote 不能删除我矩阵中的引号?

标签 r

在 r 中创建学校日历很酷,为什么 noquote 函数不能删除我矩阵中的引号?

start<-as.Date("2013-09-02")
x<-start+0:139
rows<-paste(1:20,"th","week",sep="")
cols<-c("mon","tue","wed","thu","fri","sat","sun") 
y<-matrix(noquote(as.character(format(x,"%m%d"))),nrow=20,byrow=TRUE,dimnames=list(rows,cols))
y
          mon    tue    wed    thu    fri    sat    sun   
1thweek  "0902" "0903" "0904" "0905" "0906" "0907" "0908"
2thweek  "0909" "0910" "0911" "0912" "0913" "0914" "0915"
(omitted.....)

为什么我无法获取格式:

        mon    tue    wed    thu    fri    sat    sun   
1thweek  0902  0903   0904 0905 0906 0907 0908
(omitted.....)

最佳答案

交换对 matrixnoquote 的调用。比较:

matrix(letters, nrow = 2)
## [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
## [1,] "a"  "c"  "e"  "g"  "i"  "k"  "m"  "o"  "q"  "s"   "u"   "w"   "y"  
## [2,] "b"  "d"  "f"  "h"  "j"  "l"  "n"  "p"  "r"  "t"   "v"   "x"   "z"  
matrix(noquote(letters), nrow = 2)
## [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
## [1,] "a"  "c"  "e"  "g"  "i"  "k"  "m"  "o"  "q"  "s"   "u"   "w"   "y"  
## [2,] "b"  "d"  "f"  "h"  "j"  "l"  "n"  "p"  "r"  "t"   "v"   "x"   "z" 
noquote(matrix(letters, nrow = 2))
## [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
## [1,] a    c    e    g    i    k    m    o    q    s     u     w     y    
## [2,] b    d    f    h    j    l    n    p    r    t     v     x     z 

关于r - 为什么 noquote 不能删除我矩阵中的引号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19289658/

相关文章:

r - 具有交互式 x 和 y 的 Shiny ggplot 不会将信息传递给画笔

r - 按多个组对特定行求和

如果条件未找到匹配项,则返回which()的值

r - 在创建 R 模型中安装包 - AzureML

regex - R 如何处理正则表达式中的特殊字符?

r - 如何使用按钮更新 Shiny 的数据表

r - 如何在 bookdown 中添加新语言以突出显示

r - R 中 gc() 结果的解释

r - 如何使用数据框的元素,例如哈希键/字典键/主键?

r - 如何用kables中的空白替换0