Displaying 1 result from an estimated 1 matches for "shadmax".
Did you mean:
shadowmax
2009 Apr 10
3
Determine the Length of the Longest Word in a String
...d in a more straightforward way.
Short sample code --
> shadstr <- c("My string of words with varying lengths. Longest word is
nine - 1 22 333 999999999 4444")
> shadvector <- unlist(strsplit(shadstr, split=" "))
> shadvlength <- lapply(shadvector,nchar)
> shadmaxind <- which.max(shadvlength) ## Maximum element
> shadmax <- nchar(shadvector[shadmaxind])
> shadmax
[1] 9
Many thanks for your help and suggestions.
Shad
[[alternative HTML version deleted]]