[NTG-context] Can anyone connect context to R or python?

Kelley, Claire ckelley at air.org
Sat Oct 6 19:08:39 CEST 2018

I also just got an incredibly helpful answer over on stack overflow : https://tex.stackexchange.com/questions/453868/how-can-i-use-context-and-r-together
Which shows how to use Lua and filter together 

On 10/6/18, 1:06 PM, "ntg-context on behalf of Aditya Mahajan" <ntg-context-bounces at ntg.nl on behalf of adityam at umich.edu> wrote:

>On Sat, 6 Oct 2018, Kelley, Claire wrote:
>> Again thank you everyone for their incredibly helpful advice and responsiveness!
>> The work flow I am envisioning is:
>> 1) Use R to read in a csv file, filter according to some rules and then use propensity score matching (based on r packages) to create a model.
>> 2) The final data output is a table with standardize coefficients and mean values.
>> 3) This final data output is then used to create a table using Context/ Tikz to create the very specific format that I need for the final report.
>Is the final post-processed data a table that can be saved to a CSV file? 
>If so, the simplest solution will be to write R code (inside a \startR ... 
>\stopR environment) that does the post-processing and saves the data as a 
>CSV file.
>Both ConTeXt and TikZ can easily read CSV table and format as desired.
>I also want to take this opportunity to express my views on intefacing 
>with external programs. The file based interaction provided by the filter 
>module is okay for small projects but it is not ideal. Slightly better is 
>to use pipes (popen to a REPL) or use FFI 
>(e.g https://adityam.github.io/context-blog/post/interfacing-with-julia), 
>but neither of these is easy to implement and needs to be done on a 
>per-language basis. Henri Menke had a Tugboat article on this as well.
>In my opinion, a better long-term option is to write a jupyter client in 
>lua that can be called by context. Then we can easily interface with all 
>languages that provide a jupyter kernel 
>The interface of a jupter-client is available here
>https://jupyter-client.readthedocs.io/en/stable/index.html. It seems 
>relatively straight forward (send a JSON message and receive a JSON 
>message). Translating the JSON messages to ConTeXt should also be easy. 
>Is there anyone who wants to play around trying to implement this?
>If your question is of interest to others as well, please add an entry to the Wiki!
>maillist : ntg-context at 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

More information about the ntg-context mailing list