Re: [Rd] can we override "if" in R?

2017-03-05 Thread Hadley Wickham
On Sun, Mar 5, 2017 at 8:13 PM, Gábor Csárdi wrote: > Because the S3 class system is very informal. E.g. if you happen to > have an `if.whatever` function, that will be automatically a method of > your generic. For example: x <- structure(1:10, class = "test") t(x) #> #> One Sample t-test #> #>

Re: [Rd] can we override "if" in R?

2017-03-05 Thread Michael Lawrence
On Sat, Mar 4, 2017 at 12:36 PM, Da Zheng wrote: > In my case, I create a new type of matrices and override matrix > operations in R for these matrices. > My goal is to make the system as transparent as possible, which means > my system should execute the existing R code without modification. > T

Re: [Rd] can we override "if" in R?

2017-03-05 Thread Da Zheng
On Sun, Mar 5, 2017 at 2:50 PM, Michael Lawrence wrote: > > > On Sat, Mar 4, 2017 at 12:36 PM, Da Zheng wrote: >> >> In my case, I create a new type of matrices and override matrix >> operations in R for these matrices. >> My goal is to make the system as transparent as possible, which means >> m

[Rd] length(unclass(x)) without unclass(x)?

2017-03-05 Thread Henrik Bengtsson
I'm looking for a way to get the length of an object 'x' as given by base data type without dispatching on class. Something analogous to how .subset()/.subset2(), e.g. a .length() function. I know that I can do length(unclass(x)), but that will trigger the creation of a new object unclass(x) whic

[Rd] Please add me to bugzilla

2017-03-05 Thread Bradley Broom
Please add me to R bugzilla. Thanks, Bradley [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

Re: [Rd] can we override "if" in R?

2017-03-05 Thread Gabriel Becker
Da, I've been following this thread and I'm still confused as to exactly what you want/why you want it. I'm probably just missing some context here, but, If() doesn't operate on matrices, generally. Can you give an example of the type of code you want to have continue to run that requires if oper

Re: [Rd] can we override "if" in R?

2017-03-05 Thread William Dunlap via R-devel
Da Zheng would like to override 'if' and 'while' to accept more than scalar logicals and Martin Maechler would like to change 'if' to accept only scalar logicals. No one has mentioned '||' and '&&', which also want scalar logicals. Perhaps a solution is to have all of these call a new generic fun

Re: [Rd] can we override "if" in R?

2017-03-05 Thread Mark.Bravington
I can't comment for Da, but one example where the ability to make 'if' generic would have been desirable: A couple of years ago I wrote S3 classes and methods for 1-byte integers and logicals stored as raw vectors, in order to handle massive amounts of genetic data (by the standards of the day)