phpSerialize {phpSerialize} | R Documentation |
Serializes R objects for PHP import into an associative array. Main use is for building web pages with R-support.
phpSerialize(x, file = NULL, append = FALSE, associative = "1D", simplifyMono=TRUE, phpTestCode = FALSE) phpSerializeAll(include=NULL, exclude=NULL, file = NULL, append = FALSE, associative = "1D", simplifyMono=TRUE, phpTestCode = FALSE)
x |
an object |
file |
a file name or a connection, or NULL to return the output as a string. If the connection is not open it will be opened and then closed on exit. |
append |
append or overwrite the file? |
associative |
a character string of |
simplifyMono |
if TRUE (default), unnamed vectors of length 1
are reduced to scalars, which is easier to understand in PHP.
For |
phpTestCode |
if TRUE, php test code for direct display of the associative PHP-array is added. |
include |
a vector of characters strings of the objects in
|
exclude |
a vector of character strings of objects excluded from
serialization. Partial matching is used, so |
See the sample
directory for an extended test case and
the web
directory for an Apache-tested web application.
Matrices with dimensions > 2 and complex numbers are currently not supported.
Returns a string if file=NULL, or NULL if a file argument was supplied.
For example, phpSerialize(c("a","b"))
produces the output string
a:2:{i:1;s:1:"a";i:2;s:1:"b";}
,
giving Array([1]=>a,[2]=>b)
after unserializing in PHP.
Code was tested mainly with lm, lme and nlme.
Dieter Menne (dieter.menne@menne-biomed.de)
Serialize PHP: http://jpspan.sourceforge.net/examples/serialize_php.php. Manual PHP: http://www.php.net/manual/en/index.php
# htest object wc = wilcox.test(rnorm(10)+2,rnorm(10)+5) phpSerialize(wc) #lm summary group = gl(2,10,20, labels=c("Ctl","Trt")) weight = c(rnorm(10)+10, rnorm(10)+6) sumlm = summary(lm(weight ~ group)) phpSerialize(sumlm,phpTestCode=TRUE) phpSerializeAll(include="w",exclude="sum",phpTestCode=TRUE)