Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- myrefclass <- function(str) {
- methods <- list()
- methods$cnt <- function() {
- return(length(str))
- }
- methods
- }
- v1 <- c("ABC", "D", "FGHI")
- v2 <- c(ABC="ABC", D="D", FGHI="FGHI")
- res1 <- sapply(v1, myrefclass)
- res2 <- sapply(v2, myrefclass)
- > res1["ABC"]$cnt
- NULL
- > res2["ABC"]$cnt
- NULL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement