Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. myrefclass <- function(str) {
  2. methods <- list()
  3.  
  4. methods$cnt <- function() {
  5. return(length(str))
  6. }
  7.  
  8. methods
  9. }
  10.  
  11. v1 <- c("ABC", "D", "FGHI")
  12. v2 <- c(ABC="ABC", D="D", FGHI="FGHI")
  13.  
  14. res1 <- sapply(v1, myrefclass)
  15. res2 <- sapply(v2, myrefclass)
  16.  
  17. > res1["ABC"]$cnt
  18. NULL
  19. > res2["ABC"]$cnt
  20. NULL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement