0

I have the following chunk code

## Generamos  modelo (CAFEINA incluído)

```{r tidy=TRUE}
(modelo<-randomForest(diagnostico~.,data=datos.entreno))

# La importancia de las variables
vimp<-as.data.frame(modelo$importance)
vimp[order(vimp$MeanDecreaseGini),,drop=FALSE]


# Hacer predicciones
predicciones <- predict(modelo, datos.test)
predicciones

# Matriz de confusión
(mc <- with(datos.test,table(predicciones, diagnostico)))
```

when it is converted in pdf format, it looks like this:

enter image description here

How can I add spaces in the "yellow" places I marked?. What i want is to separate a little bit more the R code from the previous output piece.

Lev
  • 693
  • 1
  • 8
  • 24
  • 1
    You can use latex code in your pdf, so for me that would be the go to solution. Did you try something like adding [\vspace{}](http://www.personal.ceu.hu/tex/spacebox.htm) between the chuncks?But maybe there is somewhat nicer solution available. – Annet Feb 22 '20 at 13:24

1 Answers1

0

You want to include in the output both the R code and the results. The inclusion of additional commands in R code will bring them to the output as well. Thus, you may consider splitting of R chunk into several pieces in order to add space by means of tex. Here are the three options to add space between code chunks.

## Generamos  modelo (CAFEINA incluído)
```{r tidy=TRUE}
(modelo<-randomForest(diagnostico~.,data=datos.entreno))
```
&nbsp;         <!-- Option #1 -->
&nbsp;
```{r tidy=TRUE}
# La importancia de las variables
vimp<-as.data.frame(modelo$importance)
vimp[order(vimp$MeanDecreaseGini),,drop=FALSE]
```
\leavevmode
\newline       <!-- Option #2 -->
```{r tidy=TRUE}
# Hacer predicciones
predicciones <- predict(modelo, datos.test)
predicciones
```
\vspace{30mm}  <!-- Option #3 -->
```{r tidy=TRUE}
# Matriz de confusión
(mc <- with(datos.test,table(predicciones, diagnostico)))
```
DzimitryM
  • 561
  • 1
  • 5
  • 13
  • Thanks. I didnt find any other way. I will Split my code in several chunck blocks. – Lev Feb 23 '20 at 04:22