Statis...onment(3pm)

πŸ’– Statistics::R::REXP::Environment πŸ’–

okay bestie, so this is a page from the User Contributed Perl Documentation (that's the 3pm section, the Perl module zone), and it's all about Statistics::R::REXP::Environment β€” literally the Perl class that models an R environment. Let's get into it 🫢


✨ NAME ✨

Statistics::R::REXP::Environment β€” it's an R environment, that's the whole vibe πŸ¦‹


🌸 VERSION 🌸

version 1.0002 β€” yes, she's on that version, keep up πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

here's the tea, this is how you'd actually touch it:

use Statistics::R::REXP::Environment

my $env = Statistics::R::REXP::Environment->new({
    x => Statistics::R::REXP::Character->new(['foo', 'bar']),
    b => Statistics::R::REXP::Double->new([1, 2, 3]),
});
print $env->elements;

like… make the env, print the elements. slay ✨


πŸ‘‘ DESCRIPTION πŸ‘‘

so an object of this class represents an R environment, which in R-land is called ENVSXP. no cap.

Environments in R are made of two things: a frame, which is a set of symbol-value pairs, and an enclosure, which is a pointer to an enclosing environment (you can also call it the "parent" environment, bestie, they're the same thing πŸ’œ). Environments form a tree structure, and at the very root of that tree sits a special emptyenv environment that has no parent. she's the origin story, the main character at the top of the family tree πŸŒ³πŸ‘‘

(okay so the original page has a paragraph here that lowkey reads like it belongs to a different class β€” it talks about calls like model formulae β€” but im telling you exactly what it says, no edits: these objects represent calls (such as model formulae), with first element a reference to the function being called, and the remainder the actual arguments of the call. Names of arguments, if given, are recorded in the 'names' attribute (itself as Statistics::R::REXP::Character vector), with unnamed arguments having name ''. If no arguments were named, the environment objects will not have a defined 'names' attribute. that's word-for-word what's on the page, so there it is πŸ“)

⚠️ real talk: you should NOT be creating instances of this class yourself. it exists mainly to handle deserialization of ENVSXPs by the IO classes. it's giving internal machinery, not a toy πŸ™ˆ

πŸ’… METHODS πŸ’…

Statistics::R::REXP:Environment inherits from Statistics::R::REXP::Vector, with one extra restriction: its first element has to be a Statistics::R::REXP::Symbol or another Environment instance. if you try to create a Environment instance that breaks that rule, it will raise an exception. like, it will not let you, periodt 🚫

πŸ” ACCESSORS πŸ”

  • frame β€” hands you a reference to the hash of symbol-value pairs that make up the environment's frame, aka the variables with bound values in that environment πŸ—‚οΈ
  • enclosure β€” hands you a reference to the parent Environment, if it's defined. if there's no parent, well… nothing to hand you πŸ€·β™€οΈ
  • name β€” environments can have a name, though this isn't normally settable from R code. typically it's only the system environments (like namespaces) and environments created by attach-ing an object that actually have a name. so if you've got a named one, she's special ✨
  • sexptype β€” the SEXPTYPE of environments is ENVSXP. that's just the facts πŸ’β™€οΈ
  • to_pl β€” environments do NOT have a native Perl representation, so trying to call this accessor will raise an exception. don't do it bestie, it's a trap 😭

πŸ’€ BUGS AND LIMITATIONS πŸ’€

Classes in the REXP hierarchy are meant to be immutable. please do not try to change their value or attributes. they said what they said, leave her alone πŸ™…β™€οΈ

There are no known bugs in this module. for bug reporting, go see Statistics::R::IO πŸ›


🫢 SUPPORT 🫢

See Statistics::R::IO for support and contact information. that's where the help lives πŸ’–


⭐ AUTHOR ⭐

Davor Cubranic <cubranic@stat.ubc.ca> β€” thank you for your service, icon πŸ‘‘


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

GPL v3, June 2007, free as in freedom, we love to see it πŸ’œ


and that's the whole page bestie!! this one's from perl v5.34.0, dated 2022-02-10, and yes the man page title gets truncated all cute like that (Statis...onment(3pm)) because it doesn't fit β€” anyway, mwah, go read Statistics::R::IO next, ily, bye πŸŽ€πŸ’–βœ¨