RE: [R] string concatenation operator

2005-02-24 Thread Prof Brian Ripley
On Fri, 25 Feb 2005, Henrik Bengtsson wrote: .Primitive() does not necessarily apply non-S3 generic function, cf. as.character(). You mean `imply'? In fact "+" *is* S3 generic and has methods defined: methods("+") [1] +.Date +.POSIXt It is also group-generic, part of the Ops group with many more

RE: [R] string concatenation operator

2005-02-24 Thread Henrik Bengtsson
; <- function(...) UseMethod("||") "||.default" <- .Primitive("||") "||.character" <- function(...) paste(...,sep="") "abc" || "def" || "ghi" The "&" or "|" operators are nice but probably not

Re: [R] string concatenation operator

2005-02-24 Thread Spencer Graves
encer Graves [mailto:[EMAIL PROTECTED] Sent: Thursday, February 24, 2005 3:46 PM To: Gabor Grothendieck Cc: r-help@stat.math.ethz.ch Subject: Re: [R] string concatenation operator Can we do something to make the following work: > "+.character" <- function(x,y) paste(x,y,sep=&qu

RE: [R] string concatenation operator

2005-02-24 Thread Liaw, Andy
I believe not, because: > get("+") .Primitive("+") i.e., it's not an S3 generic. Andy > From: Spencer Graves > > Can we do something to make the following work: > > > "+.character" <- function(x,y) paste(x,y,sep="") > > "abc"+"def" > Error in "abc" + "def" : non-numeric argument to b

RE: [R] string concatenation operator

2005-02-24 Thread McGehee, Robert
t be re-defined FYI, your S3 method wouldn't work anyway as the arguments for the + operator are e1, e2 not x, y. -Original Message- From: Spencer Graves [mailto:[EMAIL PROTECTED] Sent: Thursday, February 24, 2005 3:46 PM To: Gabor Grothendieck Cc: r-help@stat.math.ethz.ch Subject: Re: [R] st

Re: [R] string concatenation operator

2005-02-24 Thread Spencer Graves
Can we do something to make the following work: > "+.character" <- function(x,y) paste(x,y,sep="") > "abc"+"def" Error in "abc" + "def" : non-numeric argument to binary operator Thanks, spencer graves Gabor Grothendieck wrote: Harris A. Jaffee jhmi.edu> writes: : Why doesn't R hav

Re: [R] string concatenation operator

2005-02-24 Thread Gabor Grothendieck
Harris A. Jaffee jhmi.edu> writes: : Why doesn't R have one, like "." in Perl or juxtaposition in awk? You could define one like this: R> "%+%" <- function(x,y) paste(x,y,sep="") R> "abc" %+% "def" [1] "abcdef" __ R-help@stat.math.ethz.ch mailing li

[R] string concatenation operator

2005-02-24 Thread Harris A. Jaffee
Why doesn't R have one, like "." in Perl or juxtaposition in awk? It does not seem impossible to introduce one, if that would be reasonable. It would seem to involve adding a table entry to main/names.c for the binary operator and a corresponding internal function, say do_dot(). This cannot be s