简体   繁体   中英

Knitr not wrapping lines in R code chunks

I have problem with my R code blocks in my knitr reports, they don't wrap lines in almost all of my blocks with a R code.

在此处输入图片说明

It's a typical Rmd file with blocks like this:

```{r}
batch_merged <- sqldf(c("update batch_merged set winning = 'mix' where (Homophily_Count BETWEEN 1 AND Agents_Count - 1) or (Heterophily_Count BETWEEN 1 AND Agents_Count - 1) or (Preferential_Count BETWEEN 1 AND Agents_Count - 1)", "select * from batch_merged"))
batch_merged <- sqldf(c("update batch_merged set winning = 'hom' where Homophily_Count = Agents_Count", "select * from batch_merged"))
batch_merged <- sqldf(c("update batch_merged set winning = 'het' where Heterophily_Count = Agents_Count", "select * from batch_merged"))
batch_merged <- sqldf(c("update batch_merged set winning = 'pre' where Preferential_Count = Agents_Count", "select * from batch_merged"))
winning <- sqldf("select OptionGroup, sum(CASE WHEN winning='hom' THEN 1 ELSE 0 END) as homophily, sum(CASE WHEN winning='het' THEN 1 ELSE 0 END) as heterophily, sum(CASE WHEN winning='pre' THEN 1 ELSE 0 END) as preferential, sum(CASE WHEN winning='mix' THEN 1 ELSE 0 END) as mixed from batch_merged group by OptionGroup")
# print.data.frame(winning)
```

And I create the report with this instruction:

knit2html("raport-partC.Rmd","raport-parcC.html")

My sessioninfo:

> library(knitr)
> sessionInfo()
R version 3.1.1 (2014-07-10)
Platform: x86_64-pc-linux-gnu (64-bit)

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

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

other attached packages:
[1] knitr_1.9

loaded via a namespace (and not attached):
[1] evaluate_0.5.5 formatR_1.1    stringr_0.6.2  tools_3.1.1  

Any ideas appreciated. Thanks!

According to comments, I should first format properly my R code to stick with a constant width of character, than after knitting - in case if there are still any problems at all - edit manually my page and CSS. I'm closing this question when possible. Thanks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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