Reputation: 7404
I have some R code to update a database stored in update_db.ipynb
. When I try to %run update_db.ipynb
from a jupyter notebook with a python kernel, I get an error
File "<ipython-input-8-815efb9473c5>", line 14
city_weather <- function(start,end,airports){
^
SyntaxError: invalid syntax
Looks like it thinks that update_db.ipynb
is written in python. Can I specify which kernel to use when I use %run
?
Upvotes: 1
Views: 791
Reputation: 1146
Your error is not due to the kernel selected. Your command %run
is made to run python only, but it has to be a script, not a notebook. You can check in details the ipython magic commands
For your use case I would suggest to install both python and R kernel in jupyter. Then you can use the magic cell command %%R
to select to run R kernel for a cell inside the python notebook. Source :this great article on jupyter - tip 19
Other solution is to put your R code in an R script, and then execute it from a jupyter notebook. For this you can run a bash command from a jupyter notebook that will execute the script
!R path/to/script.r
Upvotes: 2