Dear Aditya, > Le 15 juin 2020 à 01:45, Aditya Mahajan <adit...@umich.edu> a écrit : > > This is an adapted version of the code that I use for my course where I use > the vim module to do the typesetting: > > \usemodule[filter] > \usemodule[vim] > > \definecolor [darkblue] [r=0.1, g=0.11, b=0.84] > \definecolor [darkgreen] [g=0.7] > \definecolor [lightblue] [h=87cefa] > \definecolor [lightgreen] [g=0.95,b=0.8,r=0.8] > > \defineframedtext > [leftbartext] > [ > width=local, > frame=off, > framecolor=darkblue, > leftframe=on, > rulethickness=1ex, > offset=0.25ex, > loffset=3ex, > background=color, > backgroundcolor=lightblue, > ] > > \definevimtyping > [RCODE] > [ > syntax=r, > directory=output, > strip=yes, > escape=yes, > before={\blank[quarterline]\startleftbartext}, > after={\stopleftbartext}, > ] > > \define[1]\ShowOutput > {\typeRCODEfile{\externalfilterinputfile} > \startleftbartext[framecolor=darkgreen, backgroundcolor=lightgreen] > \setupalign[flushleft, verytolerant] > % range={1,-1} not currently supported > % See below for details > \typefile[range={1,-1}]{#1} > \stopleftbartext} > > > \defineexternalfilter > [R] > [ filtercommand={R CMD BATCH -q --no-timing --save --restore > \externalfilterinputfile\space \externalfilteroutputfile}, > output=\externalfilterbasefile.out, > directory=output, > readcommand=\ShowOutput, > read=no, > cache=yes, > purge=yes, % THE COMMA WAS MISSING > ] > > \starttext > > Some text... > > \startR[read=yes] > pdf("RPlots/MyHistogram.pdf",5,5) > X <- rnorm(200,mean=10,sd=2) > hist(X, col = "red3" , xlab="Score QI" , main="", ylab="fréquence") > \stopR > > \externalfigure[RPlots/MyHistogram.pdf][width=.5\textwidth] > > \stoptext > >
Thanks so much for your answer. I had (of course) to install nvim in order the code to work, but this works ! Thanks also for your additional work regarding the locale setting.. this is really deep magic for me. I think the facility to run R code directly from context can open ConTeXt to new users. The alliance between R and LaTeX is a winning combination to a lot of my colleagues. Do you think this would be appropriate to do a simple page on the wiki explaining how R code can be done in ConTeXt, with eventual formatting, with some simple examples, or this is too much noise ? Thanks. Fabrice. ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________