Comments (8)
Ok. There is a sequence
function, though.
from 2017-04-03-adv-r-progr-embl.
So what is the preferred solution here, something like this?
setMethod("sequence", "ANY", function(object,...) base::sequence(object))
from 2017-04-03-adv-r-progr-embl.
Added in: ab05dc0
from 2017-04-03-adv-r-progr-embl.
I think it should be
.A <- setClass("A", slots = c(a = "numeric"))
a <- .A(a = 1)
setGeneric("sequence", function(nvec, ...) standardGeneric("sequence"))
setMethod("sequence", "ANY", function(nvec) base::sequence(nvec))
setMethod("sequence", "A", function(nvec) print("A.sequnece"))
sequence(1:3)
sequence(a)
from 2017-04-03-adv-r-progr-embl.
base::sequence() is not a generic, so there is no obligation to keep the same parameter names?
from 2017-04-03-adv-r-progr-embl.
- Set generic, that doesn't exists.
Not sure if we need to usenvec
here. Will test. - Default implementation, that calls the base function, to recover it.
- New method for our class.
from 2017-04-03-adv-r-progr-embl.
Indeed, we can rename the argument:
.A <- setClass("A", slots = c(a = "numeric"))
a <- .A(a = 1)
setGeneric("sequence", function(x, ...) standardGeneric("sequence"))
setMethod("sequence", "ANY", function(x) base::sequence(x))
setMethod("sequence", "A", function(x) print("A.sequence"))
sequence(1:3)
sequence(a)
from 2017-04-03-adv-r-progr-embl.
Alright then, I'll keep it as it is in the commit quoted above.
from 2017-04-03-adv-r-progr-embl.
Related Issues (5)
- Material in the intro HOT 1
- Testing material HOT 3
- Package dependencies
- Javadoc in R? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from 2017-04-03-adv-r-progr-embl.