From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/107726 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 02:04:40 -0400 (EDT) Message-ID: References: Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-736962766-1592201080=:1528" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="103109"; 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 08:05:10 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 1jkiF4-000Qj8-0I for gctc-ntg-context-518@m.gmane-mx.org; Mon, 15 Jun 2020 08:05:10 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id D0547162E6F; Mon, 15 Jun 2020 08:04:44 +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 dOHXgo_MROnR; Mon, 15 Jun 2020 08:04:43 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id D2C6F163AC7; Mon, 15 Jun 2020 08:04:43 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id E2B32163AC7 for ; Mon, 15 Jun 2020 08:04:42 +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 iNNwe5hPqMXI for ; Mon, 15 Jun 2020 08:04:42 +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 (smtp.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 1F187162E6F for ; Mon, 15 Jun 2020 08:04:41 +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 97D27F78C1 for ; Mon, 15 Jun 2020 02:04:40 -0400 (EDT) In-Reply-To: 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:107726 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-736962766-1592201080=:1528 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE On Mon, 15 Jun 2020, Aditya Mahajan wrote: > On Sun, 14 Jun 2020, Fabrice L wrote: > >> Hi, >>=20 >> Following a question about the broken R module (R the statistical=20 >> software), Aditya suggested me the filter module (thanks to him). I=E2= =80=99m about=20 >> to distribute a set of course notes to colleagues, and I need to deal wi= th=20 >> details now. I have one problem and two questions. >>=20 >> 1) the filter collect R code between \startR / \stopR and submit this co= de=20 >> to R. As it can be seen in the following minimal example, when a label= =20 >> contains an accented character (=C2=AB Fr=C3=A9quence =C2=BB in my examp= le), the pdf=20 >> graphic does not contains the =C2=AB =C3=A9 =C2=BB. Strangely, the snipp= et of code (which=20 >> is saved locally as =C2=AB test2-temp-R-0.tmp =C2=BB (for test2.tex)) wh= en submitted=20 >> with the same command as the filtercommand, works correctly; that means = the=20 >> same file works when submitted to R outside of ConTeXt. I have no idea h= ow=20 >> to solve this. > > Are you running the exact same command as the `filtercommand`. If so, I d= on't=20 > know why running the `filtercommand` through context vs directly typing i= t on=20 > the terminal should behave differently. The filter module effectively jus= t=20 > runs os.execute("filtercommand"). I don't use R so I am unable to debug= =20 > further. I can reproduce this output side the filter module. If I directly run os.ex= ecute(...) from a lua session, the output is correct but running it through= context gives the wrong output. I am guessing this is something to do with= locale. I notice that the output of os.execute("locale") from context is d= ifferent from that from my shell. But I don't know why locale should affect= UTF characters in R. Perhaps someone with more knowledge of R can comment = on that. \starttext \startluacode lfs.mkdir("output/") \stopluacode \startbuffer[code] pdf("output/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") \stopbuffer \savebuffer[prefix=3Dno, list=3Dcode, file=3D{output/code.r}] \startluacode print(">>>>", "RUNNING R CMD") os.execute("R CMD BATCH --no-timing --save --restore output/code.r outpu= t/out") \stopluacode \externalfigure[RPlots/MyHistogram.pdf][width=3D.5\textwidth] \stoptext Aditya --8323329-736962766-1592201080=: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-736962766-1592201080=:1528--