Re: [R] All anchored series from a vector?

From: Gabor Csardi <csardi_at_rmki.kfki.hu>
Date: Tue, 18 Dec 2007 22:10:37 +0100

On Wed, Dec 19, 2007 at 12:01:25AM +0100, Johannes Graumann wrote:
> Debugged version:
> lapply(1:length(myvector), function(.length) {
> myvector[1:.length]
> })
>
> Thanks for showing the direction!
>
> Joh

Note that this fails if length(myvector)==0. Good to know the corner cases.

Gabor

>
> markleeds@verizon.net wrote:
>
> >>From: Johannes Graumann <johannes_graumann_at_web.de>
> >>Date: 2007/12/18 Tue PM 04:40:37 CST
> >>To: r-help_at_stat.math.ethz.ch
> >>Subject: [R] All anchored series from a vector?
> >
> > lapply(1:length(myvector) function(.length) {
> > c(myvector[1}:myvector[.length])
> > })
> >
> > but test it because i didn't.
> >
> >
> >
> >>Hi all,
> >>
> >>What may be a smart, efficient way to get the following result:
> >>
> >>myvector <- c("A","B","C","D","E")
> >>myseries <- miracle(myvector)
> >>myseries
> >>[1]
> >>[[1]] "A"
> >>[2]
> >>[[1]] "A" "B"
> >>[3]
> >>[[1]] "A" "B"
> >>[4]
> >>[[1]] "A" "B" "C"
> >>[5]
> >>[[1]] "A" "B" "C" "D"
> >>[6]
> >>[[1]] "A" "B" "C" "D" "E"
> >>
> >>Thanks for any hints,
> >>
> >>Joh
> >>
> >>______________________________________________
> >>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.
> >
> > ______________________________________________
> > 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.
>
> ______________________________________________
> 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.

-- 
Csardi Gabor <csardi_at_rmki.kfki.hu>    MTA RMKI, ELTE TTK

______________________________________________
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.
Received on Tue 18 Dec 2007 - 21:14:28 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 18 Dec 2007 - 22:30:19 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.