简体   繁体   English

字符串中的 R markdown 换行符(R Studio)

[英]R markdown line break within a string (R Studio)

In regular R code I can do the following (when I put pointer at long_string and execute:在常规 R 代码中,我可以执行以下操作(当我将指针放在long_string并执行时:

long_string <- 'a
b'

So if I have a very long string then I can just hit Enter to split it and R Studio will understand.因此,如果我有一个很长的字符串,那么我可以Enter来拆分它,R Studio 会理解。

In R-markdown the above does not work在 R-markdown 上面不起作用

```{r string test, echo = F}

long_string <- 'a
b'

```

If I put pointer at long_string and execute, I will end up with + in console, meaning that R is expecting end of line command.如果我将指针放在long_string并执行,我将在控制台中以+结束,这意味着 R 正在等待行尾命令。

One solution is to select whole expression (multiple lines) and run it, but I wonder if there are other solutions.一种解决方案是 select 整个表达式(多行)并运行它,但我想知道是否还有其他解决方案。

In Markdown, instead of activating the console via ctrl + ENTER you might want to run the entire Markdown Chunk by pressing CTRL + SHIFT + ENTER .在 Markdown 中,您可能希望通过按CTRL + SHIFT + ENTER来运行整个 Markdown 块,而不是通过ctrl + ENTER激活控制台。 Then you'll obtain the result right below the chunk.然后您将在块的正下方获得结果。

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

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