.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Statistics::R::IO::REXPFactory 3pm" .TH Statistics::R::IO::REXPFactory 3pm "2022-02-10" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Statistics::R::IO::REXPFactory \- Functions for parsing R data files .SH "VERSION" .IX Header "VERSION" version 1.0002 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Statistics::R::IO::REXPFactory qw( unserialize ); \& \& # Assume $data was created by reading, say, an RDS file \& my ($rexp, $state) = @{unserialize($data)} \& or die "couldn\*(Aqt parse"; \& \& # If we\*(Aqre reading an RDS file, there should be no data left \& # unparsed \& die \*(AqUnread data remaining in the RDS file\*(Aq unless $state\->eof; \& \& # the result of the unserialization is a REXP \& say $rexp; \& \& # REXPs can be converted to the closest native Perl data type \& print $rexp\->to_pl; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module implements the actual reading of serialized R objects and their conversion to a Statistics::R::REXP. You are not expected to use it directly, as it's normally wrapped by \&\*(L"readRDS\*(R" in Statistics::R::IO and \*(L"readRData\*(R" in Statistics::R::IO. .SH "SUBROUTINES" .IX Header "SUBROUTINES" .ie n .IP "unserialize $data" 4 .el .IP "unserialize \f(CW$data\fR" 4 .IX Item "unserialize $data" Constructs a Statistics::R::REXP object from its serialization in \&\f(CW$data\fR. Returns a pair of the object and the Statistics::R::IO::ParserState at the end of serialization. .IP "intsxp, langsxp, lglsxp, listsxp, rawsxp, realsxp, refsxp, strsxp, symsxp, vecsxp, envsxp, charsxp, cplxsxp, closxp, expsxp, s4sxp" 4 .IX Item "intsxp, langsxp, lglsxp, listsxp, rawsxp, realsxp, refsxp, strsxp, symsxp, vecsxp, envsxp, charsxp, cplxsxp, closxp, expsxp, s4sxp" Parsers for the corresponding R SEXP-types. .IP "object_content" 4 .IX Item "object_content" Parses object info and its data by sequencing \*(L"unpack_object_info\*(R" and \*(L"object_data\*(R". .IP "unpack_object_info" 4 .IX Item "unpack_object_info" Parser for serialized object info structure. Returns a hash with keys \*(L"is_object\*(R", \*(L"has_attributes\*(R", \*(L"has_tag\*(R", \*(L"object_type\*(R", and \&\*(L"levels\*(R", each corresponding to the field in R serialization described in . An additional key \*(L"flags\*(R" contains the full 32\-bit value as stored in the file. .ie n .IP "object_data $obj_info" 4 .el .IP "object_data \f(CW$obj_info\fR" 4 .IX Item "object_data $obj_info" Parser for a serialized R object, using the object type stored in \&\f(CW$obj_info\fR hash's \*(L"object_type\*(R" key to use the correct parser for the particular type. .ie n .IP "vector_and_attributes $object_info, $element_parser, $rexp_class" 4 .el .IP "vector_and_attributes \f(CW$object_info\fR, \f(CW$element_parser\fR, \f(CW$rexp_class\fR" 4 .IX Item "vector_and_attributes $object_info, $element_parser, $rexp_class" Convenience parser for vectors, which are serialized first with a \&\s-1SEXP\s0 for the vector elements, followed by attributes stored as a tagged pairlist. Attributes are stored only if \f(CW$object_info\fR indicates their presence, while vector elements are parsed using \&\f(CW$element_parser\fR. Finally, the parsed attributes and elements are used as arguments to the constructor of the \f(CW$rexp_class\fR, which should be a subclass of Statistics::R::REXP::Vector. .IP "header" 4 .IX Item "header" Parser for header of R serialization: the serialization format (\s-1XDR,\s0 binary, etc.), the version number of the serialization (currently 2), and two 32\-bit integers indicating the version of R which wrote the file followed by the minimal version of R needed to read the format. .IP "xdr, bin" 4 .IX Item "xdr, bin" Parsers for \s-1RDS\s0 header indicating files in \s-1XDR\s0 or native-binary format. .IP "maybe_long_length" 4 .IX Item "maybe_long_length" Parser for vector length, allowing for the encoding of 64\-bit long vectors introduced in R 3.0. .IP "tagged_pairlist_to_rexp_hash" 4 .IX Item "tagged_pairlist_to_rexp_hash" Converts a pairlist to a \s-1REXP\s0 hash whose keys are the pairlist's element tags and values the pairlist elements themselves. .IP "tagged_pairlist_to_attribute_hash" 4 .IX Item "tagged_pairlist_to_attribute_hash" Converts object attributes, which are serialized as a pairlist with attribute name in the element's tag, to a hash that can be used as the \f(CW\*(C`attributes\*(C'\fR argument to Statistics::R::REXP constructors. .Sp Some attributes are serialized using a compact encoding (for instance, when a table's row names are just integers 1:nrows), and this function will decode them to a complete \s-1REXP.\s0 .SH "BUGS AND LIMITATIONS" .IX Header "BUGS AND LIMITATIONS" There are no known bugs in this module. Please see Statistics::R::IO for bug reporting. .SH "SUPPORT" .IX Header "SUPPORT" See Statistics::R::IO for support and contact information. .SH "AUTHOR" .IX Header "AUTHOR" Davor Cubranic .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is Copyright (c) 2017 by University of British Columbia. .PP This is free software, licensed under: .PP .Vb 1 \& The GNU General Public License, Version 3, June 2007 .Ve