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

2018-10-05 Thread Kelley, Claire
Hi All,
I am very interested in creating pdf documents using Context with calculations 
done in R or Python and then added into the document.

If you were using traditional latex this could be accomplished through R 
markdown or Sweave- is there any way to connect these to Context?

Best,
Claire
___
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
___

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

2018-10-05 Thread Kelley, Claire
Thank you for all the answers so far !



Ive gathered from that I need to use filter to call R externally.

 What I am still most interested in is how I could get a single value from R to 
be part of the Context code. (Like you would do with \Sexpr{} in sweave. The 
use case for this is that I have some complicated tikz code that makes a fancy 
matrix - I want to fill it in with numbers that r reads from a csv file and 
processes. 
 

On 10/5/18, 1:48 PM, "ntg-context on behalf of Pablo Rodriguez" 
 wrote:

>Lua
___
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
___

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

2018-10-06 Thread Kelley, Claire
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. 
 
I can do this using Sweave, but I need to be able to  use context for some 
additional features (in particular the tagging/back end structure). 

Best, 
Claire 




On 10/5/18, 2:07 PM, "Hans Hagen"  wrote:

>On 10/5/2018 8:00 PM, Kelley, Claire wrote:
>> Thank you for all the answers so far !
>> 
>> 
>> 
>> Ive gathered from that I need to use filter to call R externally.
>> 
>>   What I am still most interested in is how I could get a single value from 
>> R to be part of the Context code. (Like you would do with \Sexpr{} in 
>> sweave. The use case for this is that I have some complicated tikz code that 
>> makes a fancy matrix - I want to fill it in with numbers that r reads from a 
>> csv file and processes.
>Can you give an example? Do you only need R for reading the csv?
>
>Hans ntg-context@ntg.nl
>
>
>-
>   Hans Hagen | PRAGMA ADE
>   Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
>-
>
___
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
___

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

2018-10-06 Thread Kelley, Claire
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 
Claire 



On 10/6/18, 1:06 PM, "ntg-context on behalf of Aditya Mahajan" 
 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 
>(https://github.com/jupyter/jupyter/wiki/Jupyter-kernels).
>
>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?
>
>Aditya
>___
>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
>___
___
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
___

[NTG-context] External Figure add caption or alternative text for tagged pdf/x

2018-12-11 Thread Kelley, Claire
Hi All.

I am trying to embed an image in a pdf so that when you open the pdf in acrobat 
or another reader the image is correctly tagged as an image and there is 
alternative text. So far I am able to export the back end tags so that I can 
see tags on tables and paragraphs, but the image comes through tagged as a 
paragraph and I am unable to add any alternative text. This is the code I am 
using:


\setupbackend
  [format=PDF/X-1a:2001,
   export=yes]

\externalfigure[district.pdf][height=10cm]



Does anyone have any idea how I could fix this?

Thanks!
Claire
___
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
___