Web Development with R



Similar documents
Web Development with R

Introduction Simple Web Application Advanced Web Application IRT tool Screenshots. IRTTool.com. Building web applications with R.

Introduction to Web Development with R

A Tool for Evaluation and Optimization of Web Application Performance

Speed up your web site. Alan Seiden Consulting alanseiden.com

An introduction to creating Web 2.0 applications in Rational Application Developer Version 8.0

How To Test Your Web Site On Wapt On A Pc Or Mac Or Mac (Or Mac) On A Mac Or Ipad Or Ipa (Or Ipa) On Pc Or Ipam (Or Pc Or Pc) On An Ip

Bug Report. Date: March 19, 2011 Reporter: Chris Jarabek

Rich-Internet Anwendungen auf Basis von ColdFusion und Ajax

This course provides students with the knowledge and skills to develop ASP.NET MVC 4 web applications.

Example. Represent this as XML

Intro to Web Programming. using PHP, HTTP, CSS, and Javascript Layton Smith CSE 4000

10CS73:Web Programming

Version 1.0 January Xerox Phaser 3635MFP Extensible Interface Platform

WIRIS quizzes web services Getting started with PHP and Java

Implementing Mobile Thin client Architecture For Enterprise Application

DiskPulse DISK CHANGE MONITOR

Web Performance First Aid. Alan Seiden Consulting alanseiden.com

Shipbeat Magento Module. Installation and user guide

Developing a Web Server Platform with SAPI Support for AJAX RPC using JSON

ArcGIS Server mashups

GUI and Web Programming

Course Information Course Number: IWT 1229 Course Name: Web Development and Design Foundation

603: Enhancing mobile device experience with NetScaler MobileStream Hands-on Lab Exercise Guide

Session D15 Simple Visualization of your TimeSeries Data. Shawn Moe IBM

Platform Independent Mobile Application Development

IBM Script Portlet for WebSphere Portal Release 1.1

AUTOMATED CONFERENCE CD-ROM BUILDER AN OPEN SOURCE APPROACH Stefan Karastanev

HtmlUnit: An Efficient Approach to Testing Web Applications

Using Ajax for Desktop-like Geospatial Web Application Development

RGU Honours Project (Soft Real-time Data Viewer using WITSML)

Visualizing a Neo4j Graph Database with KeyLines

Advanced Web Development SCOPE OF WEB DEVELOPMENT INDUSTRY

LabVIEW Internet Toolkit User Guide

Web Development using PHP (WD_PHP) Duration 1.5 months

An introduction to creating JSF applications in Rational Application Developer Version 8.0

Fachgebiet Technische Informatik, Joachim Zumbrägel

Developing ASP.NET MVC 4 Web Applications

Developing ASP.NET MVC 4 Web Applications Course 20486A; 5 Days, Instructor-led

Introducing Apache Pivot. Greg Brown, Todd Volkert 6/10/2010

DreamFactory & Modus Create Case Study

Design Approaches of Web Application with Efficient Performance in JAVA

Tutorial: Building a Dojo Application using IBM Rational Application Developer Loan Payment Calculator

ADOBE ACROBAT CONNECT ADD-IN FOR MICROSOFT OUTLOOK USER GUIDE

Google Web Toolkit. Introduction to GWT Development. Ilkka Rinne & Sampo Savolainen / Spatineo Oy

Progressive Enhancement With GQuery and GWT. Ray Cromwell

Selenium WebDriver. Gianluca Carbone. Selenium WebDriver 1

General principles and architecture of Adlib and Adlib API. Petra Otten Manager Customer Support

Embedded BI made easy

Building native mobile apps for Digital Factory

Load Testing Ajax Apps using head-less browser tools. NoVaTAIG April 13, 2011 Gopal Addada and Frank Hurley Cigital Inc.

Web-JISIS Reference Manual

MASTERTAG DEVELOPER GUIDE

Outline. CIW Web Design Specialist. Course Content

DESIGN AND IMPLEMENTATION OF A FILE SHARING APPLICATION FOR ANDROID

Load testing with. WAPT Cloud. Quick Start Guide

Web development... the server side (of the force)

Proposal Submission System - A Content Management System Approach for Proposal Submission

Advantage of Jquery: T his file is downloaded from

QUICK START GUIDE. Cloud based Web Load, Stress and Functional Testing

How to start with 3DHOP

MBARI Deep Sea Guide: Designing a web interface that represents information about the Monterey Bay deep-sea world.

IBM Digital Experience. Using Modern Web Development Tools and Technology with IBM Digital Experience

G563 Quantitative Paleontology. SQL databases. An introduction. Department of Geological Sciences Indiana University. (c) 2012, P.

Liferay Portal User Guide. Joseph Shum Alexander Chow

Lucy Zhang UI Developer Contact:

Visualization of Semantic Windows with SciDB Integration

Checking Browser Settings, and Basic System Requirements for QuestionPoint

Elgg 1.8 Social Networking

Web Design Specialist

Introduction to the. Barracuda Embedded Web-Server

Load Testing with JMeter

Developing ASP.NET MVC 4 Web Applications MOC 20486

exacqvision Web Server Quick start Guide

Software Development & Education Center PHP 5

25 Tips for Creating Effective Load Test Scripts using Oracle Load Testing for E-Business Suite and Fusion Applications.

A Model of the Operation of The Model-View- Controller Pattern in a Rails-Based Web Server

FileMaker Server 15. Custom Web Publishing Guide

Performance Testing for Ajax Applications

Apache JMeter HTTP(S) Test Script Recorder

Application layer Web 2.0

Visualizing an OrientDB Graph Database with KeyLines

How To Write An Ria Application

soapui Product Comparison

3DHOP Local Setup. Lezione 14 Maggio 2015

Web Intrusion Detection with ModSecurity. Ivan Ristic

Getting Started Guide with WIZ550web

Struts Tools Tutorial. Version: M5

Internationalizing JavaScript Applications Norbert Lindenberg. Norbert Lindenberg All rights reserved.

PHP on IBM i: What s New with Zend Server 5 for IBM i

Continuous Integration

HP Business Service Management

Programming Fundamentals of Web Applications Course 10958A; 5 Days

Transcription:

Web Development with R UCLA Statistics Seminar Jeroen Ooms jeroenooms@gmail.com November 2009, Los Angeles

What is a Web Application Some examples: yeroon.net/ggplot2 [video] yeroon.net/lme4 [video] Pubertyplot [video] Stockplot [video] IRT tool [video]

What is a Web Application This presentation is about: Making Web Interfaces for Simple R applications. R runs on the server. User only needs a standard webbrowser. Programming in R and HTML/Javascript (No Java!). AJAX interfaces. It is not about: Applications that require advanced queueing systems for running multiple simultaneous R jobs. Distributed Computing. Java.

Why Web Applications? Convenient: Making new tools available to a wide audience. User only needs a standard webbrowser. Cross-platform. Server-based by design: Efficient use of resources. Easier to maintain. Integration with existing services/databases/etc. Because you have to: More and more services only available from the browser. Many people can t or dont want to install software.

Hello World! RApache RApache is a module for the Apache web server. It allows you to embed R scripts in a webpage. It is one of the ways of connecting the HTTPD to R. Demo: Brew scripting. GET/POST. Try Catch.

Web application Setup Server Client Request/Response Workstation Calling R Interface

ggplot2 example 1. Interface: Interactive webpage with menu, buttons, layer list, etc, that enables the user to specify a plot. 2. Request: A configuration of a plot to draw (settings, mappings, layers) 3. Server: Decodes the configuration, and draws the requested figure. 4. Response: The plot figure. 5. Interface: Updates figure within the page, and makes appropriate changes in GUI.

The Message Specification Where the magic happens: How to get objects from the client s browser into R on the server? HTTP basically only takes strings for arguments. Protocol Design: Maintain a request object in the browser (client). Define a way to encode your javascript object into a string. Use this string as argument to an HTTP/AJAX request. Decode the string on the server back to an object. Idem for the response message.

Message Specification: XML and JSON. For advanced web applications use a standard data format to communicate with the server. 2 obvious candidates: XML and JSON. You can use CRAN packages XML and rjson for parsing. XML is most widely used, probably preferable if you want to integrate your application in other software (consider SOAP). JSON is lighter and supports array s. Preferred for large datasets.

Example of XML Syntax <mymodel> <family>gaussian</family> <deviance>3569.23</deviance> <coefficients> <coef> <name>intercept</name> <value>5.69</value> </coef> <coef> <name>age</name> <value>0.36</value> </coef> <coef> <name>gender</name> <value>2.54</value> </coef> </coefficients> </mymodel>

Example of JSON Syntax {"mymodel": { "family": "Gaussian", "deviance": 3569.23, "coefficients": [ {"Intercept": 5.69}, {"Age": 0.36}, {"Gender": 2.54} ] } } Or for example a dataframe: {"mydata": { "Age":[9,8,12,6,7,8,9,8,10,11,9,6,8], "Gender":["M","F","F","M","F","M","F","F","M","F","M","F","F"], "Treatment":[1,0,0,1,1,1,0,0,0,1,1,1,0] } }

Example: lme4

Javascript fragment function fitmodel(){ Ext.Ajax.request({ timeout: 60000, url:../brew/lme-model, method: POST, params: { lmerequest: Ext.util.JSON.encode(request) }, success: function(o){ try{ result = Ext.decode(o.responseText); } updateparameters(result.modelfit); } }); }

lme Request Request Object: { } "thismodelnumber":1, "reml":true, "dependent":"reaction", "datafile":95806, "DVfamily":"gaussian", "fixediv":["intercept","days"], "randomiv":[{ "group":"subject", "varname":"113subject", "predictors":["intercept","days"] }]

Server Fragment (R) fitmodel <- function(){ lmerequest <- fromjson(as.character(post$lmerequest)); reml <- as.logical(lmerequest$reml); dependent <- lmerequest$dependent; DVfamily <- lmerequest$dvfamily; fixediv <- lmerequest$fixediv; randomiv <- lmerequest$randomiv; datafile <- lmerequest$datafile; thismodelnumber <- lmerequest$thismodelnumber; # do some parsing and then: load(datafile); mymodel <- glmer(modelformula, family=dvfamily, data=mydata); } #extract information from mymodel, and store it in a list return(tojson(outputlist));

Response Object: { lme Response success:true, modelfit:{ "formula":"1 + Days + (1+Days Subject)", "termlabels":["days"], "dataclasses":{"reaction":"numeric","days":"numeric"}, "fixef":[ { "id":"1", "name":"(intercept)", "estimate":"251.405", "SE":"6.825", "tvalue":"36.836", "assign":"0", "factor":"intercept" }, { "id":"2", "name":"days", "estimate":" 10.467", "SE":"1.546", "tvalue":" 6.770", "assign":"1", "factor":"days" } ],... (continues)

lme Response continued } } "CorMatrix":[[1,0.066],[0.066,1]]}], "REML":"TRUE", "LL":-871.814, "Deviance":1743.628, "DF":6, "Sigma":25.592, "AIC":1774.786, "BIC":1755.628, "randomcovmatrices":[ { "group":"subject", "fields":["(intercept)","days"], "CovMatrix":[[612,9.6],[9.6,35.1]] } ]

Some Advice Use Firefox + Webdev toolbar + firebug for development. Design a protocol that makes sense semantically. Don t use R to generate Layout or HTML. This soon become unmanageble. Only computing at the server, do all layout stuff at the client.

Connecting your HTTPD to R RApache/brew: Plugin for Apache webserver + scripting package. New R session for every http request. Fast, good caching. Calling Rscript from php/cgi No need for extra plugins. Works on windows. Extra sensitive to code injection! Rserve: Keeps an R session alive. Requires additional Rserve client. If session gets messed up, you re screwed.

Security Watch out for code injection! Parse user data safely. Don t let a user specify which function to run. If necessary, remove any weird characters from argument strings.

Graphical Interfaces There are many free and open-source javascript libraries that provide ready-to-use interfaces and widgets. Easily create Grids, Tabs, Windows, Drag/drop, Trees, Forms, Toolbars, etc with only a few lines of code. Framework Prototype/Scriptaculous Yahoo! User Interface Library (YUI) jquery Dojo Ext License MIT BSD GPL or MIT BSD GPL or Commercial

Thank you for your attention! Jeffrey Horner (2009). rapache: Web application development with R and Apache. http://biostat.mc.vanderbilt.edu/rapache/ Hadley Wickham (2009). ggplot2: An implementation of the Grammar of Graphics. http://cran.r-project.org/package=ggplot2 van Buuren S, Ooms JCL (2009). Stage line diagram: An age-conditional reference diagram for tracking development. Statistics in Medicine. w3schools: Full Web Building Tutorials - All Free.