Re: [Rd] "if" function in pure R?

2019-05-26 Thread Alexandre Courtiol
Thanks a lot Jiefei, I had thought of defining a binary operator (inspired by pipes) or simply using an additional condition in the if() calls [e.g. if(foo & fn(bar)) doSomeThing; with fn(bar) returning a logical], but both are workaround that I do not find as elegant as a proper control-flow cons

Re: [Rd] "if" function in pure R?

2019-05-26 Thread King Jiefei
Hi Alexandre, I'm not an R expert so this is only my personal thought: I don't think you can achieve what you want exactly. A possible solution would be defining a binary operator %*%, where you can replace the asterisk with any function name you want. The function %*% is special since it has two

Re: [Rd] rbind has confusing result for custom sub-class (possible bug?)

2019-05-26 Thread Joshua Ulrich
On Sun, May 26, 2019 at 4:06 AM Michael Chirico wrote: > > Have finally managed to come up with a fix after checking out sys.calls() > from within the as.Date.IDate debugger, which shows something like: > > [[1]] rbind(DF, DF) > [[2]] rbind(deparse.level, ...) > [[3]] `[<-`(`*tmp*`, ri, value = 18

Re: [Rd] rbind has confusing result for custom sub-class (possible bug?)

2019-05-26 Thread Michael Chirico
Have finally managed to come up with a fix after checking out sys.calls() from within the as.Date.IDate debugger, which shows something like: [[1]] rbind(DF, DF) [[2]] rbind(deparse.level, ...) [[3]] `[<-`(`*tmp*`, ri, value = 18042L) [[4]] `[<-.Date`(`*tmp*`, ri, value = 18042L) [[5]] as.Date(val

[Rd] "if" function in pure R?

2019-05-26 Thread Alexandre Courtiol
Hi all, Could anyone refer to me to a good source to learn how to program a simple control-flow construct* in R, or provide me with a simple example? Control-flow constructs are programmed as primitives, but I would like to be able to do that (if possible) in pure R. The general context is that