Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- foo <- function(n, s = NULL, t = NULL, f = NULL){
- d <- if(!is.null(t)) t + n else if(!is.null(f)) f^2 + n
- m <- if(!is.null(s)) s/2 else NULL
- r <- if(!is.null(m)) m + 1 else NULL
- if(!is.null(m) & is.null(m)) d <- m + r
- out <- data.frame(d)
- rownames(out) <- paste0("BB", 1:length(d))
- out
- }
- # Example of use:
- foo(n = 30:35, s = 1:2, t = 3:5, f = 7)
- ## OUTPUT:
- d
- BB1 33 # add "t" to the rownames of `d`s computed from "t" or "f" for ds computed from "f"
- BB2 35
- BB3 37
- BB4 36
- BB5 38
- BB6 40
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement