Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running an R kernel #9

Open
louisaslett opened this issue Jun 1, 2021 · 2 comments
Open

Running an R kernel #9

louisaslett opened this issue Jun 1, 2021 · 2 comments

Comments

@louisaslett
Copy link

I've seen R successfully used on some fabulous sites building off Juniper such as https://noamross.github.io/gams-in-r-course/ However, I would like to use Juniper outside of the spaCy course framework, so am trying to use the juniper.min.js file directly and embed in the framework I'm using.

However, even with the most basic test file I can't seem to get it to use an R language kernel. Just to get started, I'm using the existing Binder build at ines/course-starter-r so that I can eliminate that as a problem. So, based on the attributes for repo/branch/kernelType/language at https://github.com/ines/course-starter-r/blob/master/meta.json I'm trying this:

<html>
  <head>
    <title>Juniper with R</title>
  </head>
  <body>

<pre data-executable>
x <- rnorm(10)
mean(x)
x
</pre>

<script src="juniper.min.js"></script>
<script>new Juniper({
    repo: 'ines/course-starter-r',
    branch: 'binder',
    kernelType: 'ir',
    language: 'r'
})</script>

  </body>
</html>

However, when I run, I get errors which show that the code has been run through the Python interpreter, not R. Any guidance would be massively appreciated as I can't understand what I'm doing wrong.

Thanks,

Louis

@sedv8808
Copy link

Hi @louisaslett
I know this issue is pretty old but wondering if you were able to figure this out as I am running with the same issue.
When I try to run

library("something")

I receive the error

NameError: name 'library' is not defined

which is clearly a Python error :( I have no idea how to solve it and would love to use juniper for some presentations in R.

@louisaslett
Copy link
Author

Hey!

Unfortunately I never did figure this out, so I ended up "scratching the itch" myself and wrote a very simple little environment to work for the specific use case I needed (which is code blocks in bookdown lecture notes), with robustness the top priority (I don't want to be constantly having to reboot the backend).

It doesn't work with BinderHub, but instead you need to launch a cheap virtual server (such as a Digital Ocean droplet, eg $5/mo) to use. I've not altogether fully documented things yet, because I was running it just with my courses this academic year for alpha testing (which has gone very well: zero crashes or issues in 6 months+), so it's on my summer to-do after exam marking to document this properly and make it suitable for widespread use. You can see examples of it in action at my DSSC course (quick running example in black box on that page for Monte Carlo estimation of pi where students can experiment changing code) or my StatML course (scroll down to black box after Example 4.1 for a longer-running example).

The code is at https://github.com/louisaslett/surfeR and there is probably just enough detail to get it going if you are interested to try.

It's not in that repo just yet, but I've got a little code I can share to make it easy to embed the editable blocks with 1 line in RMarkdown/bookdown without writing Javascript directly, should you happen to have the same use case as me (will be releasing this publicly this summer with the docs, but do reach out if you'd like to use it now). Should this match your needs I'd be very happy to help in any way over email -- someone else testing this would be super and help me with identifying what needs to be explained for writing the full docs soon. If it's not quite a match, then no worries!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants