Search notes:

R function: body

f <- function(x, y) {
  if (x > 0) {
    x * y;
  } else {
    y - x;
  }
}

b <- body(f);

typeof(b);
#
#  "language"

class(b);
#
#  "{"

mode(b);
#
#  "call"

is.language(b);
#
#   TRUE

f(2, 3);
#
#  6

body(f) <- x + y ;

f(2, 3);
Github repository about-r, path: /functions/body/body.R

body(body)

body(body);
#
#  {
#      if (is.character(fun)) 
#          fun <- get(fun, mode = "function", envir = parent.frame())
#      .Internal(body(fun))
#  }
Github repository about-r, path: /functions/body/body-of-body.R

eval(…)

fun <- function(a, b) {
  a * b;
}

bod <- body(fun);

eval(bod, list(a=6, b=7));
#
#  42
Github repository about-r, path: /functions/body/eval.R

See also

Functions in R
environment, 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...', 1758201058, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/R/functions/body(104): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78