Guest User

Untitled

a guest
Nov 14th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. setClass("MyDb", representation(data = "data.frame", version = "character"))
  2.  
  3. setMethod("$", signature = "MyDb",
  4. function(x, name) { return(x@data[[name]]) }
  5. )
  6.  
  7. db <- new("MyDb", data = mtcars, version = "2.3.1")
  8.  
  9. library(sp)
  10. data("meuse")
  11. coordinates(meuse) <- ~ x + y
  12. meuse$ # brings up autocomplete options for meuse@data slot
  13.  
  14. # in MyDb.R
  15. names.MyDb <- function(x) names(x@data)
  16.  
  17. # in NAMESPACE
  18. S3method(names,MyDb)
Add Comment
Please, Sign In to add comment