Change Google colaboratory default language as R
Contents
Note
Without doing below, you may see a GUI menu on Colab;
Runtime > Change runtime type, then change the type of runtime into
I’m not sure what enables this settings because some notebooks seem not have options for changing the type of runtime. If you do not see the options, below procedure would be an alternative.
Runtime > Change runtime type, then change the type of runtime into
R
.I’m not sure what enables this settings because some notebooks seem not have options for changing the type of runtime. If you do not see the options, below procedure would be an alternative.
Option1. Create notebook with R language from URL endpoint
Below link enables blank noteboook with default kernel language R.
https://colab.research.google.com/notebook#create=true&language=r
Option2. Change notebook kernel spec on Google Colab
For setting Google Colaboratory default language as R (from python), I tweaked the .ipynb file as below.
- Open Google colaboratory project page (.ipynb)
- File > Download > Download .ipynb
- Open the ipynb by text editor (in my case I used vim editor on Mac terminal) and change below lines:
Before
|
|
After
|
|
- Upload the changed .ipynb to the Google Colaboratory page.
Then you can call R command on Google colaboratory without typing %%R
before every execution.
Then you can run R command and packages on .ipynb file like:
|
|