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 p

Re: [Rd] Improving string concatenation

2015-06-19 Thread Martin Maechler
> Radford Neal > on Thu, 18 Jun 2015 14:32:18 -0400 writes: > Gabor Csardi writes: >> Btw. for some motivation, here is a (surely incomplete) >> list of languages with '+' as the string concatenation >> operator: >> >> ALGOL 68, BASIC, C++, C#, Cobra, Pascal,

Re: [Rd] Improving string concatenation

2015-06-18 Thread Radford Neal
Gabor Csardi writes: > Btw. for some motivation, here is a (surely incomplete) list of > languages with '+' as the string concatenation operator: > > ALGOL 68, BASIC, C++, C#, Cobra, Pascal, Object Pascal, Eiffel, Go, > JavaScript, Java, Python, Turing, Ruby, Windows Powers hell, > Objective-C, F

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 vers

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 colum

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 prob

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 demons

Re: [Rd] Improving string concatenation

2015-06-17 Thread Avraham Adler
On Wed, Jun 17, 2015 at 1:25 AM, Joshua Bradley wrote: > …I work in the bioinformatics domain and write R scripts for > pipelines with calls to various programs that require a lot of parameters > to be set/varied. Seeing "paste" everywhere detracts from reading the code > (in my opinion). In that

Re: [Rd] Improving string concatenation

2015-06-17 Thread Gábor Csárdi
On Wed, Jun 17, 2015 at 12:45 PM, William Dunlap 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 surprised

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 f

Re: [Rd] Improving string concatenation

2015-06-17 Thread Gábor Csárdi
On Wed, Jun 17, 2015 at 9:04 AM, Michael Lawrence 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, > redefining fundamental behavio

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-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. I

Re: [Rd] Improving string concatenation

2015-06-16 Thread Gabriel Becker
On Jun 16, 2015 3:44 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. I don't follow. In what sense is paste co

Re: [Rd] Improving string concatenation

2015-06-16 Thread Gábor Csárdi
On Tue, Jun 16, 2015 at 10:30 PM, Joshua Bradley 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 intended) to > the code b

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 kind

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 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 rules are sometime

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 6:32 PM, Joshua Bradley wrote: [...] > An old (2005) post > on r-help > mentioned possible performance reasons as to why this type of string > concatenation is not supported out of the box but did not go into