简体   繁体   English

从 R 中的特殊字符中删除引号

[英]Remove quotes from special characters in R

When I print pattern program in r ,当我在 r 中打印模式程序时,

 char<-c("#","@")
m<- matrix(paste(char[1]),nrow  =4, ncol = 4)
print(m)

My output is我的输出是

 [,1] [,2] [,3] [,4]
[1,] "#"  "#"  "#"  "#" 
[2,] "#"  "#"  "#"  "#" 
[3,] "#"  "#"  "#"  "#" 
[4,] "#"  "#"  "#"  "#" 

But my desired output is # without quotations.但我想要的输出是#不带引号。 I tried char method, I tried vector and I tried noquote function.我尝试了 char 方法,我尝试了 vector 并尝试了noquote函数。 But none worked for me.但没有一个对我有用。 If anyone knows the solution, help me to solve.如果有人知道解决方案,请帮我解决。

The double quotes are not actually part of the data and is just how the output is rendered by R;双引号实际上不是数据的一部分,只是 R 呈现输出的方式; however, if you knew that already and are asking how to print it without the double quotes then use noquote但是,如果您已经知道这一点并且正在询问如何在没有双引号的情况下打印它,那么请使用noquote

noquote(m)

giving:给予:

     [,1] [,2] [,3] [,4]
[1,] #    #    #    #   
[2,] #    #    #    #   
[3,] #    #    #    #   
[4,] #    #    #    #   

Also print has a quote=FALSE argument giving the same output: print也有一个quote=FALSE参数给出相同的输出:

print(m, quote = FALSE)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM