Re: [Rd] example package for devel newcomers

From: Alexandre Aguiar <asaguiar_at_spsconsultoria.com>
Date: Wed, 03 Aug 2011 02:28:34 -0300

Simon,

Thanx for your feedback.

Em Terça 02 Agosto 2011, você escreveu:
> .. also note that there is Rserve PHP client (used, e.g., by FastRWeb)
> which works around a lot of the issues you encounter when you try to
> embed R into PHP (initialization cost, lack of thread-safety, no
> workspace separation etc.).

Did not overlook Rserve. Nice piece of software.

The purpose of (to be) Rphp is different. Suppose we have php files top.php, right.php, left.php and bottom.php that build the frame around a central portion of a website's webpages. This basic scheme is used by most web content management systems (WCMS).

In a simple view things will work like:

--------R cgi script pseudocode----------- # first get data from command line
data <- getcgidata()
html.title <- function(txt) {

   print(paste"<center><h1>",txt,"</h1></center><br><br>",sep="") }
php("include '/somedir/top.php'") # php needs full path php("include '/somedir/left.php'")
# perform calculations
RES <- calculations(data)
html.title("Results")
# printout results in the RES R variable print(RES)
php("include '/somedir/right.php'")
php("include '/somedir/bottom.php'")


The intended result is to have an output fully compliant with the WCMS without messing up with WCMS itself. Besides php(), another function is implemented to get values from specific php variables, user defined or system.

BTW, libphp5.so output is directed to R cgi script output (stdout in cgi) that is sent away through the internet connection but could also be trapped and saved to a variable for further handling.

---+ pesudocode----------

php("$V1=2")
php("$V2=5;")
php("$V3=4;$V4=4")
php("$VAL=$V1+$V2+$V3-$V4")

calc_val <- php.get("VAL") # or calc_val <- php("echo $VAL")

In the php() function the semicolon statement delimiter can be omitted after the last or the only php statement.

The pseudocode operation above is not useful at all. However, any function added with php() or declared within php files included or php systemwide extensions available (PEAR libraries, for instance) can be called by R scripts. Users always get creative and despite my own limited purpose, I guess many inventive uses may appear. For instance, Berkeley db, inifiles support, time/zone database, support to exif info in jpeg and tiff files, some 20 or 30 different hashes, ftp support, JSON, SOAP client and server (this can do amazing things) can all become available to R.

Kindest regards.

-- 


Alexandre

--
Alexandre Santos Aguiar, MD, SCT

______________________________________________ R-devel_at_r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

Received on Wed 03 Aug 2011 - 05:31:47 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 03 Aug 2011 - 15:10:14 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive