Skip to content

use R namespace functions to make it easier to use existing R functions #1

@adalisan

Description

@adalisan

There is a slightly hacky way to make it simpler to use existing R packages with FlashR
say you want to override the parse function in package:base

parse=function(...){ 
    base::parse(...) 
} 
 # Find out where the function lives. 
  env <- as.environment( 'package:base' ) 

  # Crack the binding. 
  unlockBinding( 'parse', env ) 

  # Replace the function. 
  assignInNamespace( 'parse', function(...){ 
  
   # Your function here, or an object that contains it. 

   }, ns = 'base' ) 

  # Relock the binding. 
  lockBinding( 'parse', env ) 

similarly you can overload functions in stats package, etc.
It is probably not too difficult to test this for the simple mvrnorm example.
This hack is not recommended by R developers, but for FlashR users who probably don't want to go through all R code in packages they use , it's a workable solution

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions