如何在 R 中显示带引号的文本? [英] How to display text with Quotes in R?

查看:27
本文介绍了如何在 R 中显示带引号的文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开始学习 R 并且正在尝试创建如下向量:

I have started learning R and am trying to create vector as below:

c(""check"")

我需要输出为:检查".但我收到语法错误.创建向量时如何转义引号?

I need the output as : "check". But am getting syntax error. How to escape the quotes while creating a vector?

推荐答案

正如@juba 提到的,一种方法是直接转义引号.

As @juba mentioned, one way is directly escaping the quotes.

另一种方法是在包含双引号的字符表达式周围使用单引号.

Another way is to use single quotes around your character expression that has double quotes in it.

> x <- 'say "Hello!"'
> x
[1] "say \"Hello!\""
> cat(x)
say "Hello!"

这篇关于如何在 R 中显示带引号的文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆