Re: [Rd] Improving string concatenation

2015-06-24 Thread Gökçen Eraslan
On 2015-06-17 20:24, Joshua Bradley wrote: How would this new '+' deal with factors, as paste does or as the current '+' does? Would number+string and string+number cause errors (as in current '+' in R and python) or coerce both to strings (as in current R:paste and in perl's '+'). I had

Re: [Rd] Improving string concatenation

2015-06-18 Thread Hervé Pagès
Hi Joshua, On 06/17/2015 11:24 AM, Joshua Bradley wrote: How would this new '+' deal with factors, as paste does or as the current '+' does? Would number+string and string+number cause errors (as in current '+' in R and python) or coerce both to strings (as in current R:paste and in perl's

Re: [Rd] Improving string concatenation

2015-06-18 Thread MacQueen, Don
At the risk of unnecessarily (annoyingly?) prolonging a conversation that has died down... I don't think I've seen the sep or collapse arguments to paste mentioned as aspects to consider. I don't see any way in which this version of '+' could offer those arguments. Hence I would consider this

Re: [Rd] Improving string concatenation

2015-06-17 Thread William Dunlap
if '+' and paste don't change their behavior with respect to factors but you encourage people to use '+' instead of paste then you will run into problems with data.frame columns because many people don't notice whether a character-like column is character or factor. With paste() this is not a

Re: [Rd] Improving string concatenation

2015-06-17 Thread Hervé Pagès
Hi Bill, On 06/17/2015 12:36 PM, William Dunlap wrote: if '+' and paste don't change their behavior with respect to factors but you encourage people to use '+' instead of paste then you will run into problems with data.frame columns because many people don't notice whether a character-like

Re: [Rd] Improving string concatenation

2015-06-17 Thread Joshua Bradley
How would this new '+' deal with factors, as paste does or as the current '+' does? Would number+string and string+number cause errors (as in current '+' in R and python) or coerce both to strings (as in current R:paste and in perl's '+'). I had posted this sample code previously to

Re: [Rd] Improving string concatenation

2015-06-17 Thread Michael Lawrence
Just to clarify, primitive (C-level) generics do not support dispatch on basic classes (like character). This is for performance (no need to consider dispatch on non-objects) and for sanity (in general, redefining fundamental behaviors is dangerous). It is of course possible to define a + method

Re: [Rd] Improving string concatenation

2015-06-17 Thread Gábor Csárdi
On Wed, Jun 17, 2015 at 9:04 AM, Michael Lawrence lawrence.mich...@gene.com wrote: Just to clarify, primitive (C-level) generics do not support dispatch on basic classes (like character). This is for performance (no need to consider dispatch on non-objects) and for sanity (in general,

Re: [Rd] Improving string concatenation

2015-06-17 Thread William Dunlap
... adding the ability to concat strings with '+' would be a relatively simple addition (no pun intended) to the code base I believe. With a lot of other languages supporting this kind of concatenation, this is what surprised me most when first learning R. Wow! R has a lot of surprising

Re: [Rd] Improving string concatenation

2015-06-17 Thread Gábor Csárdi
On Wed, Jun 17, 2015 at 12:45 PM, William Dunlap wdun...@tibco.com wrote: ... adding the ability to concat strings with '+' would be a relatively simple addition (no pun intended) to the code base I believe. With a lot of other languages supporting this kind of concatenation, this is what

[Rd] Improving string concatenation

2015-06-16 Thread Joshua Bradley
Hi, first time poster here. During my time using R, I have always found string concatenation to be (what I feel is) unnecessarily complicated by requiring the use of the paste() or similar commands. When searching for how to concatenate strings in R, several top search results show answers that

Re: [Rd] Improving string concatenation

2015-06-16 Thread Joshua Bradley
Bad choice of words I'm afraid. What I'm ultimately pushing for is a feature request. To allow string concatenation with '+' by default. Sure I can write my own string addition function (like the example I posted previously) but I use it so often that I end up putting it in every script I write.

Re: [Rd] Improving string concatenation

2015-06-16 Thread Joshua Bradley
One of the poster's on the SO post I linked to previously suggested this but if '+' were made to be S4 compliant, then adding the ability to concat strings with '+' would be a relatively simple addition (no pun intended) to the code base I believe. With a lot of other languages supporting this

Re: [Rd] Improving string concatenation

2015-06-16 Thread Gábor Csárdi
On Tue, Jun 16, 2015 at 10:30 PM, Joshua Bradley jgbradl...@gmail.com wrote: One of the poster's on the SO post I linked to previously suggested this but if '+' were made to be S4 compliant, then adding the ability to concat strings with '+' would be a relatively simple addition (no pun

Re: [Rd] Improving string concatenation

2015-06-16 Thread Gabriel Becker
On Jun 16, 2015 3:44 PM, Joshua Bradley jgbradl...@gmail.com wrote: Hi, first time poster here. During my time using R, I have always found string concatenation to be (what I feel is) unnecessarily complicated by requiring the use of the paste() or similar commands. I don't follow. In what

Re: [Rd] Improving string concatenation

2015-06-16 Thread Gábor Csárdi
On Tue, Jun 16, 2015 at 6:32 PM, Joshua Bradley jgbradl...@gmail.com wrote: [...] An old (2005) post https://stat.ethz.ch/pipermail/r-help/2005-February/066709.html on r-help mentioned possible performance reasons as to why this type of string concatenation is not supported out of the box but

Re: [Rd] Improving string concatenation

2015-06-16 Thread Hervé Pagès
Hi Joshua, On 06/16/2015 03:32 PM, Joshua Bradley wrote: Hi, first time poster here. During my time using R, I have always found string concatenation to be (what I feel is) unnecessarily complicated by requiring the use of the paste() or similar commands. When searching for how to concatenate

Re: [Rd] Improving string concatenation

2015-06-16 Thread Gábor Csárdi
On Tue, Jun 16, 2015 at 8:24 PM, Hervé Pagès hpa...@fredhutch.org wrote: [...] If I was to override `+` to concatenate strings, I would make it stick to the recycling scheme used by arithmetic and comparison operators (which is the most sensible of all IMO). Yeah, I agree, paste's recycling