Created
May 19, 2014 16:56
-
-
Save jeroen/8751ef8edb1e47081f30 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>OpenCPU demo app</title> | |
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> | |
<!-- ocpu library --> | |
<script src="//code.jquery.com/jquery-1.10.2.min.js"> </script> | |
<script src="//public.opencpu.org/js/opencpu-0.4.js"> </script> | |
<style> | |
#plotdiv { | |
height: 400px; | |
border: solid gray 1px; | |
} | |
</style> | |
</head> | |
<body> | |
<h1>Call R to download data for a specified stock ticket and plotting it</h1> | |
<b>Ticker</b> <input type="text" value="GOOG" id="ticker"> | |
<button id="submitbutton" type="button">Submit to server!</button> <br><br> | |
<div id="plotdiv"></div> | |
<!-- input and recieve output specified using jquery, and RESTful software architectur--> | |
<script type='text/javascript'> | |
// location of R function on openCPU server | |
ocpu.seturl("//public.opencpu.org/ocpu/library/stocks/R") | |
//call R function: stocks::smoothplot(ticker=ticker) | |
$("#submitbutton").click(function(){ | |
var ticker = $("#ticker").val(); | |
var req = $("#plotdiv").rplot("smoothplot", { | |
ticker : ticker, | |
from : "2013-01-01" | |
}); | |
req.fail(function(){ | |
alert("R returned an error: " + req.responseText); | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment