Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 205372

Specifying names of arguments with a function in R

$
0
0

What I want to do is the following: I want to write a function, let's call it 'function_creator' with one argument: name, and some additional arguments, such that its output is a function for which the name of the argument is the argument I passed to 'function_creator'.

The following code-snippet illustrates how I would like function_creator to behave:

f <- function_creater(name = "y", y_min = 2, y_max = 3)
f
function(y) {
  y >= 2 && y <= 3
}

How do I do this in R?? I guess that something like sys.call() might be helpful but I don't really know how to proceed from there.


Viewing all articles
Browse latest Browse all 205372

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>