RR ver. 0.1 Remote R web app

I made a web app for running R script on any web site.

First, you need to include the following code in the header of your site.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="http://45.79.102.35/scripts/RR.css">
<script src="http://45.79.102.35/scripts/RR.js"></script>

Here are some examples:

Example 1: Display a number generated by R

pnorm(1.5)

The probability that a normally distributed variable is less than 1.5 standard deviations above the mean is


P(z<1.5) = .

The HTML code for this example is

<div id="R1" class="R hide">
<pre class="script">pnorm(1.5)</pre>
</div>
The probability that a normally distributed variable
is less than 1.5 standard deviations above the mean is <center> P(z<1.5) = <span id="R1_answer"></span>. </center>


"R1" in the first div element is a unique identifier you choose. The block <div id="..." class="R">....</div> contains the R script and optional parameters.
Obviously, R code goes in the block with class="script". The HTML tag for the script can be anything, i.e., div, span, etc. But I think the "pre" tag is most appropriate because it shows the line breaks correctly and uses a monospaced font, as shown in the next example.

Example 2: Display a plot generated by R


This graph is produced by the following R code:

[[[FIG_OPTIONS]]]height=300,width=300
t = seq(0, 3, 0.01)
y0 = 0
for(k in 1:10){
    y0 = y0 + (-1)^(k+1)*sin(2*pi*k*t)/k
}
plot(t, y0, type="l")

Here is the HTML code:

<img id="R2_figure"><br>
This graph is produced by the following R code:
<div id="R2" class="R">
<div class="settings">[[[FIG_OPTIONS]]]height=300,width=300</div>
<pre class="script">
t = seq(0, 3, 0.01)
y0 = 0
for(k in 1:10){
    y0 = y0 + (-1)^(k+1)*sin(2*pi*k*t)/k
}
plot(t, y0, type="l")
</pre>
</div>

*Note to myself: Needs warning for wrong syntax in "settings".

To be continued.