user1700890
user1700890

Reputation: 7742

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:

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.

In R-markdown the above does not work

```{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.

One solution is to select whole expression (multiple lines) and run it, but I wonder if there are other solutions.

Upvotes: 0

Views: 219

Answers (1)

CWebkas
CWebkas

Reputation: 19

In Markdown, instead of activating the console via ctrl+ENTER you might want to run the entire Markdown Chunk by pressing CTRL+SHIFT+ENTER. Then you'll obtain the result right below the chunk.

Upvotes: 2

Related Questions