SPARQL Engine for knitr

21 views
Skip to first unread message

Alex Karman

unread,
Oct 7, 2016, 3:07:42 PM10/7/16
to knitr
Hello Yihui,

Has anyone made a SPARQL engine for knitr? I love knitr and use it for everything, but unfortunately creating my own engine would be beyond my abilities. Essentially, I would like it to look like and work like the SQL engine, only for SPARQL endpoints instead of RDBMS. 

It might be very simple to do (even for me) if I can just rely on the Jena "arq" utility being on the PATH and therefore available on the command line. It would therefore act much like python, ruby, and other languages that pass the command to the operating system.  I looked at the functions in knit_engines and I am tempted to just add "sparql" to one of the vectors and see what happens, but though better of it.

Can you give me any suggestions?

Thanks,
--Alex

Yihui Xie

unread,
Oct 7, 2016, 10:47:41 PM10/7/16
to Alex Karman, knitr
I have never heard of SPARQL, and I know nothing about it. Sometimes
it is trivial to add a new engine to knitr, especially when the engine
is basically a simple command line call. Here is an example:
https://github.com/yihui/knitr/pull/876/files If "arq" is more
complicated than that, you have to study the source code of some other
engines: https://github.com/yihui/knitr/blob/master/R/engine.R

Regards,
Yihui
--
Yihui Xie <xiey...@gmail.com>
Web: http://yihui.name
> --
> You received this message because you are subscribed to the Google Groups
> "knitr" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to knitr+un...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Carl Boettiger

unread,
Oct 8, 2016, 1:13:30 AM10/8/16
to Yihui Xie, Alex Karman, knitr
It might be more straight forward to just make SPARQL queries from R with the redland package, rather than use an external engine for this.  See https://cran.r-project.org/web/packages/redland/vignettes/redland_overview.html 
--

Alex Karman

unread,
Oct 10, 2016, 10:44:41 AM10/10/16
to Carl Boettiger, Yihui Xie, knitr
Thank you so much for your quick replies. Yihui, I do think it will be as easy as adding arq="-q" in the first code block and "arq" in the second code block, like in your groovy example. Carl, thank you for suggesting the Redlands package. I have used it before, as well as the SPARQL package, and both work, but what I am trying to achieve with a knitr engine is to be able to write the query as a pretty-formatted block suitable for publications, which is what the SQL Engine allows, (instead of as a "paste0" string). My SPARQL statements are typically 20 lines long. The paste() and c() syntax around the queries adds too much clutter. What is the proper approach for so small of a modification? Do you recommend merely redefining the function in RStudio or forking the project? Thanks, --Alex



> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "knitr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to knitr+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages