Agregar un salto de línea a los bloques de código en R Markdown
Estoy utilizando el paquete knitr con R Markdown para crear un informe HTML. Estoy teniendo algunos problemas para mantener mi código en líneas separadas cuando uso '+'.
Por ejemplo,
```{r}
ggplot2(mydata, aes(x, y)) +
geom_point()
```
devolverá lo siguiente el documento HTML
ggplot2(mydata, aes(x, y)) + geom_point()
Normalmente esto está bien, pero el problema surge una vez que empiezo a agregar líneas adicionales, que quiero mantener separadas para que el código sea más fácil de seguir. Ejecutando lo siguiente:
```{r}
ggplot2(mydata, aes(x, y)) +
geom_point() +
geom_line() +
opts(panel.background = theme_rect(fill = "lightsteelblue2"),
panel.border = theme_rect(col = "grey"),
panel.grid.major = theme_line(col = "grey90"),
axis.ticks = theme_blank(),
axis.text.x = theme_text (size = 14, vjust = 0),
axis.text.y = theme_text (size = 14, hjust = 1.3))
```
El resultado será que todo el código saldrá en una línea, lo que hará que sea más difícil de seguir:
ggplot2(mydata, aes(x, y)) + geom_point() + geom_line() + opts(panel.background = theme_rect(fill = "lightsteelblue2"), panel.border = theme_rect(col = "grey"), panel.grid.major = theme_line(col = "grey90"), axis.ticks = theme_blank(), axis.text.x = theme_text (size = 14, vjust = 0), axis.text.y = theme_text (size = 14, hjust = 1.3))
Cualquier ayuda para resolver esto sería muy apreciada!