0
votes

My Rmarkdown source looks like (screenshot from RStudio):

Rstudio screenshot (notice the empty lines)

When I press CTRL+Shift+k I got view as expected (with empty lines). However, if I run the chunk (evaluate) and then compile (CTRL+Shift+k), I get:

compilse (no empty lines)

Is there any way how to preserve the empty lines in the source code? (I checked knitr options: strip.white=FALSE, tidy=TRUE, tidy.opts=list(blank=TRUE) but no joy.)

I'm using RStudio 1.0.153

Other info:

sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux 9 (stretch)

Matrix products: default
BLAS: /usr/lib/openblas-base/libblas.so.3
LAPACK: /usr/lib/libopenblasp-r0.2.19.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rvest_0.3.2     xml2_1.1.1      dplyr_0.7.1     purrr_0.2.2.2  
[5] readr_1.1.1     tidyr_0.6.3     tibble_1.3.3    ggplot2_2.2.1  
[9] tidyverse_1.1.1

loaded via a namespace (and not attached):
 [1] pbdZMQ_0.2-6     reshape2_1.4.2   haven_1.1.0      lattice_0.20-35 
 [5] colorspace_1.3-2 htmltools_0.3.6  yaml_2.1.14      base64enc_0.1-3 
 [9] XML_3.98-1.9     rlang_0.1.1      foreign_0.8-69   glue_1.1.1      
[13] selectr_0.3-1    readxl_1.0.0     modelr_0.1.0     semver_0.2.0    
[17] bindrcpp_0.2     bindr_0.1        plyr_1.8.4       stringr_1.2.0   
[21] cellranger_1.1.0 munsell_0.4.3    binman_0.1.0     gtable_0.2.0    
[25] caTools_1.17.1   psych_1.7.5      evaluate_0.10.1  knitr_1.16      
[29] forcats_0.2.0    wdman_0.2.2      curl_2.7         parallel_3.4.1  
[33] broom_0.4.2      Rcpp_0.12.11     openssl_0.9.6    backports_1.1.0 
[37] scales_0.4.1     formatR_1.5      RSelenium_1.7.1  jsonlite_1.5    
[41] mnormt_1.5-5     hms_0.3          digest_0.6.12    stringi_1.1.5   
[45] grid_3.4.1       rprojroot_1.2    tools_3.4.1      bitops_1.0-6    
[49] magrittr_1.5     lazyeval_0.2.0   pkgconfig_2.0.1  lubridate_1.6.0 
[53] httr_1.2.1       assertthat_0.2.0 rmarkdown_1.6    R6_2.2.2        
[57] nlme_3.1-131     compiler_3.4.1 
1
I cannot reproduce this.. how about a reproducible example we can copy?talat
Same here, I tried to reproduce the error, but line breaks are still visible in my compiled code.Florian
Sounds similar to github.com/rstudio/rmarkdown/issues/790 but you didn't provide a minimal self-contained reproducible example, so I have no idea. (Don't post screenshots of code/text. Post the code/text.)Yihui Xie
sorry guys - you were right, no reproducible example. I re-worked the whole question - should be better now (simpler example and defined step-by-step)xhudik

1 Answers

1
votes

As far as I can see, you can't do that with an HTML notebook. If you don't need all the special notebook features, you can ask for an html_document instead of an html_notebook and formatting will be preserved. If you do need the notebook features, you probably need to make a feature request on the rmarkdown development page https://github.com/rstudio/rmarkdown to add this.