Dear all, I have an R function which returns a list of variables; however, within the body of the function I would like to incorporate a branch based on a user selected option that will mean there will be one different variable to return based on the option value.
I was thinking of doing something like this (only an example): foo <- function(x, y, option = TRUE) { . If (option == TRUE) { z = z } else { w = w } return(list(x = x, y = y, z = ifelse(option == TRUE, z, NA), w = ifelse(option != TRUE, w, NA)) } However, I was wondering if anyone else had a better idea/method which might be more elegant? Many thanks, Luke [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.