Search notes:

R function: environment

Passing by reference

With environments, is possible to create a very crude pass by reference mechanism:
fnc <- function(x) x$val <- x$val * x$val;

lst <- list(val = 3);
fnc(lst);
lst$val;
#
# 3

env <- new.env();
env$val <- 3;
fnc(env);
env$val;
#
# 9
Github repository about-R, path: /environment/pass-by-reference.R

See also

new.env, environment, globalenv
Functions in R
body, formals
Index to (some) R functions

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758200859, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/R/functions/environment(66): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78