0

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.

enter image description here

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!

hrbrmstr
  • 77,368
  • 11
  • 139
  • 205
oski86
  • 855
  • 1
  • 13
  • 35
  • 1
    Those are single strings. How do you expect them to be wrapped? – A5C1D2H2I1M1N2O1R2T1 Apr 24 '15 at 09:56
  • In R code it can stay a single string but I hoped CSS rules would wrap them inside
     and . I think maybe this may help me: http://stackoverflow.com/questions/499137/css-how-can-i-force-a-long-string-without-any-blank-to-be-wrapped-in-xul-and . Beside 2-4 lines have more instructions which end outside box. I think I should format my code first properly before knitting..
    – oski86 Apr 24 '15 at 10:05
  • 2
    I'm guessing that you're against breaking the string manually. Your `sqldf` commands should still work even if they are broken across multiple lines. – A5C1D2H2I1M1N2O1R2T1 Apr 24 '15 at 10:19

1 Answers1

0

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.

oski86
  • 855
  • 1
  • 13
  • 35