# Execute R code online

### Use RPubs to publish R code

If the data is public and you want to show off your R skills you can use rpubs directly

You'll need to install the [knitr](https://github.com/yihui/knitr#readme) package (v0.5 or later), there is a mini-tutorial just after registration

[Create an account ](https://rpubs.com/)

### Use RStudio Cloud to publish private code.

There is a 'Cloud' version of RStudio, perfect for a quick demo. For more serious work, there is some [dedicated plans](https://rstudio.cloud/plans/free).

![](/files/-MYVh9ImPh-XdZefuu0l)

Create an account here <https://rstudio.cloud/>

### Use GoogleColab for collaborative work

This is a little-known option but it's possible to use R inside GoogleColab

Start [*rmagic*](https://rpy2.github.io/doc/latest/html/interactive.html) by executing this in a cell:

```
%load_ext rpy2.ipython
```

Then start your script by `%%R` to execute

```r
%%R

x <- 1:10

x
# it should display number from 1 to 10
```

[more details about this feature](https://towardsdatascience.com/how-to-use-r-in-google-colab-b6e02d736497)

#### Native R on GoogleColab

you can switch runtime from Python to R in the options and execute native code directly

( *tested in may 2024* )

<figure><img src="/files/fu2qjjf77tBrC3xxvWBx" alt=""><figcaption></figcaption></figure>

#### Execute R code on GitHub

[See this article](/ressources/launch-an-r-script-using-github-actions.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.rforseo.com/ressources/execute-r-code-online.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
