gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 11:42:03 24 4
gpt4 key购买 nike

在 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com