Java Mailing List Archive

http://www.r-help.com/

Home » Home (12/2007) » R Help for Statistical Computing »

[R] [R-pkgs] phpSerialize 0.8

Dieter Menne

2005-02-28


New on CRAN: phpSerialize Version 0.8
Dieter Menne, dieter.menne@(protected)

Serializes R objects for PHP import into an associative array.
Main use is for building web pages with R-support.

Has mainly been tested with lm,lme, nlme and their summaries.

A web example is provide, showing

-- How to start R from php/Apache
-- How to pass variables from php to R via Environment
-- How to create serialized php output from R
-- How to read the serialize output from php/Apache via pipe
-- How to display individual results in a table
-- How to display the structure of the associative array.

For example, the following R structure...

Delta=as.numeric(Sys.getenv("DELTA")) # Get Info from php
wc = wilcox.test(rnorm(10),rnorm(10)+Delta)

... is is piped to standard output
cat(phpSerialize(wc),"\n")

... and after deserialization

$pp = popen("$Rterm --no-save --slave 2>&1 < $RFile DELTA=$Delta","r");
// Read serialized R output via pipe.
$sWilcox=fgets($pp);
pclose($pp);
$Wilcox=unserialize($sWilcox);
print_r($Wilcox);

... prints as follows:

Array
(
[statistic] => Array
(
  [W] => 29
)

[parameter] =>
[p.value] => 0.1230055
[null.value] => Array
(
  [mu] => 0
)
[alternative] => two.sided
[method] => Wilcoxon rank sum test
[data.name] => rnorm(10) and rnorm(10) + Delta
)

_______________________________________________
R-packages mailing list
R-packages@(protected)
https://stat.ethz.ch/mailman/listinfo/r-packages

______________________________________________
R-help@(protected)
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
©2008 r-help.com - Jax Systems, LLC, U.S.A.