tests/test_import/module_S3.R

# a sample generic with two different methods (that should behave differently)
test_fun <- function(x){
  UseMethod("test_fun", x)
}

test_fun.character <- function(x){
  structure("character", class = "test_class")
}


test_fun.numeric <- function(x){
  structure("numeric", class = "test_class")
}

# a method for existing (base) generic.
print.test_class <- function(x){
  print(as.character(x))
}

Try the import package in your browser

Any scripts or data that you put into this service are public.

import documentation built on Sept. 24, 2023, 1:08 a.m.