Skip to content

Instantly share code, notes, and snippets.

@simecek
Last active January 16, 2021 13:29
Show Gist options
  • Star 29 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save simecek/019d87c55fec3839d95bbf8489dde61d to your computer and use it in GitHub Desktop.
Save simecek/019d87c55fec3839d95bbf8489dde61d to your computer and use it in GitHub Desktop.
How to add R code to your (IPython) Jupyter Notebook
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@simecek
Copy link
Author

simecek commented Mar 23, 2017

The installation of R and R magic into Jupyter notebook is described here:

https://www.datacamp.com/community/blog/jupyter-notebook-r#gs.z0gxLNc

Or you can run it all in the docker and do not care about installation

https://github.com/jupyter/docker-stacks/tree/master/datascience-notebook

And even better, you can run it all in the cloud and do not care about anything, except your credit card bill (~$0.05 / hour you actually use it)

https://simecek.github.io/blog/2017/02/17/data-science-amazon-vm-with-start/stop-functionality/

@drwecki
Copy link

drwecki commented Apr 23, 2018

Can you explain what this piece of code is doing? (also is this part of R magic or is it just part of R). Thanks, I'm just wrapping my head around R magics.

df %>%
gather("Category", "X") %>%

@raymondben
Copy link

@drwecki, the pipe operator %>% just pushes the first thing into the second, so this code is equivalent to:

gather(df, "Category", "X")

And the gather function takes data from multiple columns and collapses them into key-value pairs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment