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 <lawrence.mich...@gene.com> wrote: > > > On Sat, Mar 4, 2017 at 12:36 PM, Da Zheng <zhengda1...@gmail.com> wrote: >> >> In my case, I create a new type of matrices and override matrix >> operations in R fo

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

2017-03-04 Thread Da Zheng
sound reasonable? Best, Da On Sat, Mar 4, 2017 at 3:22 PM, Michael Lawrence <lawrence.mich...@gene.com> wrote: > I'm curious as to precisely why someone would want to do this. > > On Sat, Mar 4, 2017 at 11:49 AM, Da Zheng <zhengda1...@gmail.com> wrote: >> >> I'm

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

2017-03-04 Thread Da Zheng
> ❯ `if` <- function(a, b, c) UseMethod("if") > ❯ `if.default` <- function(a,b,c) base::`if`(a, b, c) > ❯ `if.foo` <- function(a, b, c) FALSE > ❯ a <- structure(42, class = "foo") > > ❯ if (a) TRUE else FALSE > [1] FALSE > > ❯ if (1) TRUE el

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

2017-03-04 Thread Da Zheng
.ga...@gmail.com> wrote: > You can. Perhaps needless to say, be careful with this. > > ❯ `if` <- function(...) FALSE > ❯ if (TRUE) TRUE else FALSE > [1] FALSE > > G. > > On Sat, Mar 4, 2017 at 5:36 PM, Da Zheng <zhengda1...@gmail.com> wrote: >> Hello, >>

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

2017-03-04 Thread Da Zheng
Hello, I heard we can override almost everything in R. Is it possible to override "if" keyword in R to evaluate my own object instead of a logical value? Thanks, Da __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

Re: [Rd] cross-platform portable code in CRAN Repository Policy

2017-01-28 Thread Da Zheng
...@debian.org> wrote: > > > > On 27 January 2017 at 21:54, Gábor Csárdi wrote: > > | On Fri, Jan 27, 2017 at 9:28 PM, Da Zheng <zhengda1...@gmail.com> > wrote: > > | > What major R platforms does this policy refer to? > > | > > > | > > |

[Rd] cross-platform portable code in CRAN Repository Policy

2017-01-27 Thread Da Zheng
Hello, I'm trying to submit my package to CRAN. When I read the policy, it says: Package authors should make all reasonable efforts to provide cross-platform portable code. Packages will not normally be accepted that do not run on at least two of the major R platforms. What major R platforms

Re: [Rd] compile c++ code in an R package without -g

2016-10-16 Thread Da Zheng
wrote: > > On 16 October 2016 at 09:46, Da Zheng wrote: > | I'm writing an R package that is mainly written in C++. By default, R > | CMD INSTALL creates C/C++ flags as follows: > | -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat > | -Werror=format-securit

Re: [Rd] override pmin/pmax for my own matrix

2015-12-24 Thread Da Zheng
method signature. At some point we > should solve that by introducing a binary pmin2, pmax2 as we have for > cbind and rbind. > > > On Thu, Dec 24, 2015 at 5:54 AM, Da Zheng <zhengda1...@gmail.com> wrote: >> Hello, >> >> I'm trying to override pmin and pmax for my own m

[Rd] override pmin/pmax for my own matrix

2015-12-24 Thread Da Zheng
Hello, I'm trying to override pmin and pmax for my own matrix. These two functions have ... as an argument. I tried to override them as follows: setMethod("pmax", class_name, function(x, ..., na.rm) { ... }) I use this way to override primitive functions such as min/max and it works fine.