Search code examples
rlpsolve

How to use the result of lp() as a value


I am using the lp() function, but would like to use the optimal parameter as an input for following functions. Is there a way to get them?


Solution

  • You could also use missing() to test whether or not the argument b was supplied:

    myFunc <- function(a,b){
        if(missing(b)) {
            a
        } else {
            a + b
        }
    }
    
    myFunc(3,1.5)
    # [1] 4.5
    myFunc(3)
    # [1] 3