Statis...actory(3pm)
β¨ NAME β¨
Statistics::R::IO::REXPFactory β bestie, this is the module with all the functions for parsing R data files π
it's giving parser factory realness
π VERSION π
version 1.0002 β yes she's got a number, and no she will not be elaborating πΈ
π¦ SYNOPSIS π¦
okay so here's the whole vibe in code form, no cap:
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't parse";
# If we're reading an RDS file, there should be no data left
# unparsed
die 'Unread data remaining in the RDS file' 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;
likeβ¦ look at her go πβ¨
π DESCRIPTION π
This module is the one doing the actual reading of serialized R objects and turning them into a Statistics::R::REXP. Lowkey you're not supposed to use it directly though β it's normally wrapped up all cozy by readRDS in Statistics::R::IO and readRData in Statistics::R::IO. So like, it's the backstage crew, not the main character π«Ά
π SUBROUTINES π
unserialize $dataβ builds aStatistics::R::REXPobject out of its serialization in$data. Hands you back a pair: the object itself, plus theStatistics::R::IO::ParserStatesitting at the end of serialization. iconic duo honestly πintsxp,langsxp,lglsxp,listsxp,rawsxp,realsxp,refsxp,strsxp,symsxp,vecsxp,envsxp,charsxp,cplxsxp,closxp,expsxp,s4sxpβ these are the parsers for the corresponding R SEXP-types. one for each, she's thorough πobject_contentβ parses object info and its data by sequencingunpack_object_infoand thenobject_data. two-step slay β¨unpack_object_infoβ parser for the serialized object info structure. Returns a hash with the keysis_object,has_attributes,has_tag,object_type, andlevels, each one matching the field in R serialization described at <http://cran.r-project.org/doc/manuals/r-release/R-ints.html#Serialization-Formats>. There's also an extra keyflagsholding the full 32-bit value exactly as stored in the file π₯object_data $obj_infoβ parser for a serialized R object. It peeks at theobject_typekey in the$obj_infohash so it knows which parser to bring out for that particular type. vibe check passed βvector_and_attributes $object_info, $element_parser, $rexp_classβ the convenience parser for vectors π vectors get serialized with a SEXP for the vector elements first, then attributes stored as a tagged pairlist. Attributes only get stored if$object_infosays they're present, and the vector elements get parsed using$element_parser. Then the parsed attributes and elements get handed over as arguments to the constructor of$rexp_class, which should be a subclass ofStatistics::R::REXP::Vector. teamwork makes the dream work π«Άheaderβ parser for the header of R serialization: the serialization format (XDR,binary, etc.), the version number of the serialization (currently2), and two 32-bit integers saying which version of R wrote the file, followed by the minimal version of R needed to read the format. receipts on receipts πxdr,binβ parsers for the RDS header that tell you whether the file is in XDR or native-binary format. pick your fighter πmaybe_long_lengthβ parser for vector length, and she's flexible because she allows for the encoding of 64-bit long vectors that got introduced in R 3.0. growth mindset πtagged_pairlist_to_rexp_hashβ converts a pairlist into a REXP hash whose keys are the pairlist's element tags and whose values are the pairlist elements themselves. glow up β¨tagged_pairlist_to_attribute_hashβ converts object attributes (which get serialized as a pairlist with the attribute name living in the element's tag) into a hash you can use as theattributesargument to Statistics::R::REXP constructors.
Some attributes come serialized using a compact encoding β for instance, when a table's row names are just integers 1:nrows β and this function will decode them into a complete REXP. expanding the abbreviation, we love to see it π
π BUGS AND LIMITATIONS π
There are no known bugs in this module. periodt. β¨ For bug reporting though, please go see Statistics::R::IO. she handles the complaints department π
πΈ SUPPORT πΈ
See Statistics::R::IO for support and contact information π«Ά
π AUTHOR π
Davor Cubranic <cubranic@stat.ubc.ca> β thank you for your service bestie π
π COPYRIGHT AND LICENSE π
This software is Copyright (c) 2017 by University of British Columbia.
This is free software, licensed under:
The GNU General Public License, Version 3, June 2007
and that's the whole page, bestie π§ this was perl v5.34.0, dated 2022-02-10, straight out of the User Contributed Perl Documentation collection β mwah, take care of her πβ
π¦ where this page comes from
- debian bookworm: libstatistics-r-io-perl 1.0002-2 Β· GPL-3.0-only
- debian trixie: libstatistics-r-io-perl 1.0002-2 Β· GPL-3.0-only
- ubuntu jammy: libstatistics-r-io-perl 1.0002-2 Β· GPL-3.0-only
- ubuntu noble: libstatistics-r-io-perl 1.0002-2 Β· GPL-3.0-only
- ubuntu resolute: libstatistics-r-io-perl 1.0002-2 Β· GPL-3.0-only
- ubuntu stonking: libstatistics-r-io-perl 1.0002-2 Β· GPL-3.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms