ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Filter module for R
@ 2020-06-15  3:26 Fabrice L
  2020-06-15  5:45 ` Aditya Mahajan
  0 siblings, 1 reply; 10+ messages in thread
From: Fabrice L @ 2020-06-15  3:26 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 2112 bytes --]

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. 

2) In a teaching context, we may want sometimes to show the code. The filter module actually permits to show the output of the code submitted to R (which can include or not the input commands); would it be possible to typeset the submitted code ?

3) Finally, using "R CMD BATCH… » as the filtercommand add an extra line at the end of the output file which can be typeset to visualize results. Would it be possible by a magic trick to deleter the last line of the file ?

Here is a minimal code:
% —————————————————
\usemodule[filter]

\defineexternalfilter
  [R]
  [ filtercommand={R CMD BATCH -q --no-timing --save --restore \externalfilterinputfile\space \externalfilteroutputfile},
     output=\externalfilterbasefile.out,
     directory=output,
     readcommand=\typefile,
     read=no,
     cache=yes,
     purge=yes
   ]

\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[MyHistogram.pdf][width=.5\textwidth] 

\stoptext
% —————————————————

Sorry for the three questions… and thanks for any help.
Fabrice.



[-- Attachment #1.2.1: Type: text/html, Size: 3734 bytes --]

[-- Attachment #1.2.2: MyHistogram.pdf --]
[-- Type: application/pdf, Size: 4518 bytes --]

[-- Attachment #1.2.3: Type: text/html, Size: 345 bytes --]

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-06-25 20:00 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-15  3:26 Filter module for R Fabrice L
2020-06-15  5:45 ` Aditya Mahajan
2020-06-15  6:04   ` Aditya Mahajan
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

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).