https://github.com/databio/rplugins
Demo package for how to implement plugins in R
https://github.com/databio/rplugins
Last synced: 2 months ago
JSON representation
Demo package for how to implement plugins in R
- Host: GitHub
- URL: https://github.com/databio/rplugins
- Owner: databio
- Created: 2020-07-15T20:53:33.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-07-09T02:06:26.000Z (almost 5 years ago)
- Last Synced: 2025-09-11T10:46:55.496Z (10 months ago)
- Language: R
- Size: 3.91 KB
- Stars: 0
- Watchers: 14
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Rplugins demo packages
This repo demonstrates how to write simple R plugins. There are 2 R packages here, a host package (the one that will run the plugin), and the plugin package.
The host package has a function, that would be run by a user. It does whatever the host package should do. It also runs a plugin function, if one exists.
The plugin package defines the function to be run when the host package function is run.
To communicate, the plugin package must list the host package in 'Enhances', and provide functions with names that correspond to the plugin function names expected by the host package. In this example, the function names are 'preHook' and 'postHook', but they can be anything specified in the host package.
## Demo
```R
install.packages("pluginHost", repos=NULL)
```
```R
pluginHost::hostFunction()
```
There should be no plugin functions run here, you just see hello world from the host package.
But install the plugin and run the function:
```R
install.packages("pluginHost.myPlugin", repos=NULL)
pluginHost::hostFunction()
```
Now you get some more stuff, called from the plugin package -- even though we're calling a function from the host package. These are not called if you remove the package
```R
remove.packages("pluginHost.myPlugin")
pluginHost::hostFunction()
```
## Develepment
```
devtools::document("pluginHost")
devtools::document("pluginHost.myPlugin")
```