ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Aditya Mahajan <adityam@umich.edu>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Filter module for R
Date: Mon, 15 Jun 2020 02:04:40 -0400 (EDT)	[thread overview]
Message-ID: <nycvar.YAK.7.77.987.2006150155420.1528@nqv-guvaxcnq> (raw)
In-Reply-To: <nycvar.YAK.7.77.987.2006150136000.1528@nqv-guvaxcnq>

[-- Attachment #1: Type: text/plain, Size: 2319 bytes --]

On Mon, 15 Jun 2020, Aditya Mahajan wrote:

> On Sun, 14 Jun 2020, Fabrice L wrote:
>
>> Hi,
>> 
>> Following a question about the broken R module (R the statistical 
>> software), Aditya suggested me the filter module (thanks to him). I’m about 
>> to distribute a set of course notes to colleagues, and I need to deal with 
>> details now. I have one problem and two questions.
>> 
>> 1) the filter collect R code between \startR / \stopR and submit this code 
>> to R. As it can be seen in the following minimal example, when a label 
>> contains an accented character (« Fréquence » in my example), the pdf 
>> graphic does not contains the « é ». Strangely, the snippet of code (which 
>> is saved locally as « test2-temp-R-0.tmp » (for test2.tex)) when submitted 
>> with the same command as the filtercommand, works correctly; that means the 
>> same file works when submitted to R outside of ConTeXt. I have no idea how 
>> to solve this.
>
> Are you running the exact same command as the `filtercommand`. If so, I don't 
> know why running the `filtercommand` through context vs directly typing it on 
> the terminal should behave differently. The filter module effectively just 
> runs os.execute("filtercommand"). I don't use R so I am unable to debug 
> further.

I can reproduce this output side the filter module. If I directly run os.execute(...) 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 different 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=10,sd=2)
    hist(X, col =  "red3" ,  xlab="Score QI" , main="", ylab="fréquence")
\stopbuffer

\savebuffer[prefix=no, list=code, file={output/code.r}]

\startluacode
   print(">>>>", "RUNNING R CMD")
   os.execute("R CMD BATCH --no-timing --save --restore output/code.r output/out")
\stopluacode

\externalfigure[RPlots/MyHistogram.pdf][width=.5\textwidth]

\stoptext

Aditya

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

  reply	other threads:[~2020-06-15  6:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-15  3:26 Fabrice L
2020-06-15  5:45 ` Aditya Mahajan
2020-06-15  6:04   ` Aditya Mahajan [this message]
2020-06-15  6:24     ` Aditya Mahajan
     [not found]     ` <82287b24-d781-808f-f96b-675f56224bb6@azules.eu>
2020-06-24 21:01       ` French interface - previous message = wrong title Garulfo
2020-06-24 21:35         ` Hans Hagen
2020-06-25 19:34           ` French interface Garulfo
2020-06-25 20:00             ` Wolfgang Schuster
2020-06-15 17:33   ` Filter module for R Fabrice L
2020-06-15 18:06     ` Aditya Mahajan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=nycvar.YAK.7.77.987.2006150155420.1528@nqv-guvaxcnq \
    --to=adityam@umich.edu \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).