From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/107736 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Aditya Mahajan Newsgroups: gmane.comp.tex.context Subject: Re: Filter module for R Date: Mon, 15 Jun 2020 14:06:49 -0400 (EDT) Message-ID: References: <8D212D90-B738-48C2-A31D-9F74867C6114@gmail.com> Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-1513654488-1592244409=:1528" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="31170"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Alpine 2.22 (LNX 432 2020-05-21) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Mon Jun 15 20:07:11 2020 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane-mx.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jktVm-0007zg-Rd for gctc-ntg-context-518@m.gmane-mx.org; Mon, 15 Jun 2020 20:07:10 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 7339D16334B; Mon, 15 Jun 2020 20:06:54 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Kdh9_jmSwigj; Mon, 15 Jun 2020 20:06:53 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 7B6F41609D3; Mon, 15 Jun 2020 20:06:53 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 6AEE71609D3 for ; Mon, 15 Jun 2020 20:06:52 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZZJN2BCu233m for ; Mon, 15 Jun 2020 20:06:51 +0200 (CEST) Received-SPF: Softfail (mailfrom) identity=mailfrom; client-ip=132.206.73.2; helo=orford.cim.mcgill.ca; envelope-from=adityam@umich.edu; receiver= Original-Received: from orford.cim.mcgill.ca (orford.cim.mcgill.ca [132.206.73.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id 9AE5E16099A for ; Mon, 15 Jun 2020 20:06:50 +0200 (CEST) Original-Received: from adi-thinkpad.local (198-84-255-218.cpe.teksavvy.com [198.84.255.218]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: adityam) by orford.cim.mcgill.ca (Postfix) with ESMTPSA id 647BCF553B for ; Mon, 15 Jun 2020 14:06:49 -0400 (EDT) In-Reply-To: <8D212D90-B738-48C2-A31D-9F74867C6114@gmail.com> X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.26 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: "ntg-context" Xref: news.gmane.io gmane.comp.tex.context:107736 Archived-At: This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-1513654488-1592244409=:1528 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE On Mon, 15 Jun 2020, Fabrice L wrote: > Dear Aditya, > >> Le 15 juin 2020 =C3=A0 01:45, Aditya Mahajan a =C3= =A9crit : >>=20 >> This is an adapted version of the code that I use for my course where I = use the vim module to do the typesetting: >>=20 >> \usemodule[filter] >> \usemodule[vim] >>=20 >> \definecolor [darkblue] [r=3D0.1, g=3D0.11, b=3D0.84] >> \definecolor [darkgreen] [g=3D0.7] >> \definecolor [lightblue] [h=3D87cefa] >> \definecolor [lightgreen] [g=3D0.95,b=3D0.8,r=3D0.8] >>=20 >> \defineframedtext >> [leftbartext] >> [ >> width=3Dlocal, >> frame=3Doff, >> framecolor=3Ddarkblue, >> leftframe=3Don, >> rulethickness=3D1ex, >> offset=3D0.25ex, >> loffset=3D3ex, >> background=3Dcolor, >> backgroundcolor=3Dlightblue, >> ] >>=20 >> \definevimtyping >> [RCODE] >> [ >> syntax=3Dr, >> directory=3Doutput, >> strip=3Dyes, >> escape=3Dyes, >> before=3D{\blank[quarterline]\startleftbartext}, >> after=3D{\stopleftbartext}, >> ] >>=20 >> \define[1]\ShowOutput >> {\typeRCODEfile{\externalfilterinputfile} >> \startleftbartext[framecolor=3Ddarkgreen, backgroundcolor=3Dlightgre= en] >> \setupalign[flushleft, verytolerant] >> % range=3D{1,-1} not currently supported >> % See below for details >> \typefile[range=3D{1,-1}]{#1} >> \stopleftbartext} >>=20 >>=20 >> \defineexternalfilter >> [R] >> [ filtercommand=3D{R CMD BATCH -q --no-timing --save --restore >> \externalfilterinputfile\space \externalfilteroutputfile}, >> output=3D\externalfilterbasefile.out, >> directory=3Doutput, >> readcommand=3D\ShowOutput, >> read=3Dno, >> cache=3Dyes, >> purge=3Dyes, % THE COMMA WAS MISSING >> ] >>=20 >> \starttext >>=20 >> Some text... >>=20 >> \startR[read=3Dyes] >> pdf("RPlots/MyHistogram.pdf",5,5) >> X <- rnorm(200,mean=3D10,sd=3D2) >> hist(X, col =3D "red3" , xlab=3D"Score QI" , main=3D"", ylab=3D"fr= =C3=A9quence") >> \stopR >>=20 >> \externalfigure[RPlots/MyHistogram.pdf][width=3D.5\textwidth] >>=20 >> \stoptext >>=20 >>=20 > > > Thanks so much for your answer. I had (of course) to install nvim in orde= r the code to work, but this works ! Sorry, that was a leftover. I was testing in a docker container where I did= not have vim installed. This will also work with regular vim. > 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 sim= ple page on the wiki explaining how R code can be done in ConTeXt, with eve= ntual formatting, with some simple examples, or this is too much noise ? Definitely. I think there is already a short page. But it will be good to a= dd more detailed instructions. Aditya --8323329-1513654488-1592244409=:1528 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly9jb250ZXh0LmFhbmhldC5uZXQKYXJjaGl2ZSAgOiBodHRwczovL2JpdGJ1Y2tldC5v cmcvcGhnL2NvbnRleHQtbWlycm9yL2NvbW1pdHMvCndpa2kgICAgIDogaHR0cDovL2NvbnRleHRn YXJkZW4ubmV0Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCg== --8323329-1513654488-1592244409=:1528--