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 14:06:49 -0400 (EDT)	[thread overview]
Message-ID: <nycvar.YAK.7.77.987.2006151404500.1528@nqv-guvaxcnq> (raw)
In-Reply-To: <8D212D90-B738-48C2-A31D-9F74867C6114@gmail.com>

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

On Mon, 15 Jun 2020, Fabrice L wrote:

> Dear Aditya,
>
>> Le 15 juin 2020 à 01:45, Aditya Mahajan <adityam@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 !

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

Definitely. I think there is already a short page. But it will be good to add more detailed instructions.

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 18:06 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
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 message]

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