[Rd] example package for devel newcomers

Simon Urbanek simon.urbanek at r-project.org
Wed Aug 3 16:52:31 CEST 2011


Alexandre,

thanks, I see your point. Somehow I parsed your e-mail as the inverse (and Dan's suggestion which I feel did the same didn't help ;)). Embedding PHP into R sound like fun and in fact FastRWeb would benefit from your package :).

In that light you may want to explain why you need 2-5 since the easiest way is to simply link to libphp. Given that you need wrappers for R anyway there is no point in pass-through re-exports since R can't use it anyway and other packages can as easily link to libphp. So I think you'll need to be more specific what you intend to do with 2-5 ...

As for 6, for small sources it's common to include them in the package, but anything more complex it is more common to simply require it using SystemRequirements: Admittedly, in your case it's bit more complicated because even machines that have PHP installed often don't install libphp at the system level. In addition, php has a whole separate set of "libraries" (like R packages) which makes it challenging to add it simply as a static build (which we do on OS X for most libraries, for example).

As for 7, R uses mingw gcc (see Windows FAQ, we provide all the tools) so as long as php can be built that way there should due no issues. 

Cheers,
Simon


On Aug 3, 2011, at 1:28 AM, Alexandre Aguiar wrote:

> 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



More information about the R-devel mailing list