[R] Strplit code
William Dunlap
wdunlap at tibco.com
Wed Sep 21 02:26:45 CEST 2011
Look at the help file for do.call. It is
most useful when you don't know how many
arguments will be given to the function you
are calling. E.g., if you know that the list
x is always 3 long then you can do
rbind(x[[1]], x[[2]], x[[3]])
to make a matrix out of the components, just as
do.call("rbind", x)
would. If you don't know how many rows there
will be then do.call is the way to go.
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
> -----Original Message-----
> From: MK [mailto:mdkzone at aol.com]
> Sent: Tuesday, September 20, 2011 5:13 PM
> To: William Dunlap
> Cc: Santosh; R help
> Subject: Re: [R] Strplit code
>
> Pardon my ignorance, but why is the do.call necessary? why not just execute the rbind function?
> What's the advantage in putting it in a do.call "wrapper"?
>
> On Sep 20, 2011, at 2:44 PM, William Dunlap <wdunlap at tibco.com> wrote:
>
> > In S+ do.call's first argument must be a character string
> > that gives the name of the function, so replace
> > do.call(rbind, ...)
> > with
> > do.call("rbind", ...)
> >
> > Bill Dunlap
> > Spotfire, TIBCO Software
> > wdunlap tibco.com
> > From: Santosh [mailto:santosh2005 at gmail.com]
> > Sent: Tuesday, September 20, 2011 2:55 AM
> > To: William Dunlap; R help
> > Subject: Re: [R] Strplit code
> >
> > Dear R- Splus experts,
> > In R, I have frequently used do.call with strsplit. and I have a hard time with Splus.. any
> suggestions?
> >
> > for example, the R code below:
> >
> > do.call(rbind,strsplit(paste(letters[1:10],c(1:10))," "))
> >
> > Thanks so much,
> > Santosh
> > On Fri, Dec 5, 2008 at 8:51 AM, William Dunlap <wdunlap at tibco.com<mailto:wdunlap at tibco.com>> wrote:
> > [R] Strplit code
> > pomchip at free.fr<http://free.fr> pomchip at free.fr<http://free.fr>
> > Wed Dec 3 20:52:21 CET 2008
> >
> > Dear R-users,
> >
> > The strsplit function does not exist in S-plus and I would like to
> > use it. How
> > could I reproduce the function in Splus or access to its source code?
> > Thank you in advance,
> >
> > Sebastien
> > strsplit() was added to S+ 8.0 (May 2007). At the same time
> > we changed the default regular expression style from 'basic'
> > (a.k.a. 'obsolete') to 'extended' and we added the string functions
> > sub(), gsub(), and sprintf().
> >
> > S+ 8.1 is now available (as of November 2008).
> >
> > Bill Dunlap
> > TIBCO Software Inc - Spotfire Division
> > wdunlap tibco.com<http://tibco.com>
> >
> > ______________________________________________
> > R-help at r-project.org<mailto:R-help at r-project.org> mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
> >
> > [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list