Re: [R] Determine the Length of the Longest Word in a String

2009-04-10 Thread Gabor Grothendieck
Using strapply, we extract all strings of word characters and apply nchar to each simplifying by taking the max. library(gsubfn) strapply(shadstr, "\\w+", nchar, simplify = max) See the info on the gsubfn home page: http://gsubfn.googlecode.com as well as the vignette, help file and demos. On Fr

Re: [R] Determine the Length of the Longest Word in a String

2009-04-10 Thread Marc Schwartz
On Apr 10, 2009, at 3:40 PM, Shadley Thomas wrote: Hi Everyone, I'm new to programming R and have accomplished my goal, but feel that there is probably a more efficient way of coding this. I'd appreciate any guidance that a more advanced programmer can provide. My goal -- I would like to f

Re: [R] Determine the Length of the Longest Word in a String

2009-04-10 Thread Kingsford Jones
On Fri, Apr 10, 2009 at 2:40 PM, Shadley Thomas wrote: [snip] > My question -- > It seems inefficient to determine which element is the longest and then > calculate the length of that longest element.  I was hoping to find a way to > simply return the length of the longest word in a more straightf

[R] Determine the Length of the Longest Word in a String

2009-04-10 Thread Shadley Thomas
Hi Everyone, I'm new to programming R and have accomplished my goal, but feel that there is probably a more efficient way of coding this. I'd appreciate any guidance that a more advanced programmer can provide. My goal -- I would like to find the length of the longest word in a string containing