Skip to content

Can we prepare a questionaire in R

11 messages · Mike Marchywka, Matt Shotwell, Barry Rowlingson +3 more

#
----------------------------------------
I've started to use Rapache although Rserve would also be an option.
When installed on server, your can point your html form to an rhtml
page and get the form variables in R just as with other web languages.
For writing html output, I had been using R2HTML ( see code excerpt below
from rhtml page). I had also found Cairo works ok if you don't
need X-11 for anything. 

For your specific situation however, it may be easier to just
use whatever you already have and just use R for the data analysis.
When a request for a results report is made,  send that to Rapache for
example. I would mention that I have gone to running two versions
of Apache, one with R and one with PHP, to allow for security and
easier development( I can write the php to fail nicely if the R apache
server is not up and no new security issues are exposed). 


library("Cairo")
library("R2HTML")
library("RColorBrewer")


You can of course also generate html from normal R commands, or for that
matter bash scripts etc.
#
As Mike had written, there are frameworks for web-development with R.
RApache http://www.rapache.net is one. Also, see the R package Rook:
http://cran.r-project.org/web/packages/Rook/index.html .
On Wed, 2011-06-08 at 17:26 +0530, amrita gs wrote:
Wouldn't you rather create HTML forms in HTML? See the links above to
use R for server-side scripting, for example, to receive form data from
a web browser.
#
On Wed, Jun 8, 2011 at 12:56 PM, amrita gs <ammasamritha at gmail.com> wrote:
HTML is Just Plain Text, so you can create them using R's text output
'cat' function. E.g.

cat('<form> First name: <input type="text" name="firstname" /><br
/>Last name: <input type="text" name="lastname" /></form>',
file="test.html")

 and job done. Open test.html in your web browser and there it is.

 Other packages may help you construct these things - search CRAN for
html, and also 'brewer' which is a handy package for making templates
which you can render into HTML.

 But to be honest, your question is way too general as stated to get a
decent response here.

Barry
#
On Thu, Jun 9, 2011 at 11:09 AM, amrita gs <ammasamritha at gmail.com> wrote:
Are you analysing individual forms independently and giving rapid
feedback? For example, a user puts some numbers in a box, clicks
'fit', and expects to see some parameters back and maybe a plot? Then
you need R integrated with the server.

 Or are you doing summaries of many form submissions perhaps weekly or
at the end of the study period?

 There's a problem with using R to store values coming from a web form
- concurrency. Suppose two people submit the form at more or less the
same time. If your web server back-end is using R to save the data you
need to make sure the two processes aren't trying to write to the same
file at the same time or you'll corrupt it. Databases such as Postgres
sort this out by having clever locking mechanisms.

 If you are doing 'batch' analysis like this then you don't need R
involved with the server at all, and things are much simpler. Just use
a web server back end that suits you (java servlet, PHP, python web
application framework) that takes the form data and adds it to a data
base such as Postgres or MySQL.

 Then to do the analysis, R can get the data from such DBs and you can
figure out how to produce your pie charts easily...

 You say you are a beginner in R, so best to leave it and use
something else for the web side of things. What aren't you a beginner
in?

Barry
4 days later