Yet another way of doing it:

> x <- c(2,3)
> x + rep(seq(0, by=3, length=4), each=length(x))
[1]  2  3  5  6  8  9 11 12


On Fri, May 22, 2009 at 11:01 AM, Rowe, Brian Lee Yung (Portfolio Analytics)
<b_r...@ml.com> wrote:

> So if I want to concatenate the output of multiple seq calls, there's no
> clear way to to do this?
>
> For background, I have a number of data.frames with the same structure in a
> list. I want to 'collapse' the list into a single data.frame but only
> keeping certain columns from each underlying data.frame. In my example
> below, I want to keep columns 2,3 in each underlying data.frame.
>
> I'm using do.call('cbind', my.list) and then using the statement below to
> extract only the columns I need (other details omitted for brevity). If
> there's a built-in or pre-built function to do this, I'm all eyes.
>
>
> Brian
>
> PS if this is unclear, flame away, and I'll post some code
>
> -----Original Message-----
> From: Peter Dalgaard [mailto:p.dalga...@biostat.ku.dk]
> Sent: Friday, May 22, 2009 6:20 AM
> To: Rowe, Brian Lee Yung (Portfolio Analytics)
> Cc: r-help@r-project.org
> Subject: Re: [R] Behavior of seq with vector from
>
>
> Rowe, Brian Lee Yung (Portfolio Analytics) wrote:
> ....
> > To get the value I want, I am using the following code:
> >> sort(as.vector(apply(array(c(2,3)), 1, seq, by=3,length.out=4)))
> > [1]  2  3  5  6  8  9 11 12
> >
> > So two questions:
> > 1. Is seq designed/intended to be used with a vector from argument, and
> > is this the desired behavior?
> > 2. If so, is there a cleaner way of implementing what I want?
>
> 1. Hmm, not really. NA.
>
> 2. I'd view it as an outer sum, stringed out to a single vector, hence:
>
> > c(outer(c(2,3), seq(0,,3,4), "+"))
> [1]  2  3  5  6  8  9 11 12
>
>
> --
>   O__  ---- Peter Dalgaard             Ă˜ster Farimagsgade 5, Entr.B
>  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
>  (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
> ~~~~~~~~~~ - (p.dalga...@biostat.ku.dk)              FAX: (+45) 35327907
>
>
> --------------------------------------------------------------------------
> This message w/attachments (message) may be privileged, confidential or
> proprietary, and if you are not an intended recipient, please notify the
> sender, do not use or share it and delete it. Unless specifically indicated,
> this message is not an offer to sell or a solicitation of any investment
> products or other financial product or service, an official confirmation of
> any transaction, or an official statement of Merrill Lynch. Subject to
> applicable law, Merrill Lynch may monitor, review and retain
> e-communications (EC) traveling through its networks/systems. The laws of
> the country of each sender/recipient may impact the handling of EC, and EC
> may be archived, supervised and produced in countries other than the country
> in which you are located. This message cannot be guaranteed to be secure or
> error-free. References to "Merrill Lynch" are references to any company in
> the Merrill Lynch & Co., Inc. group of companies, which are wholly-owned by
> Bank of America Corporation. Securities and Insurance Products: * Are Not
> FDIC Insured * Are Not Bank Guaranteed * May Lose Value * Are Not a Bank
> Deposit * Are Not a Condition to Any Banking Service or Activity * Are Not
> Insured by Any Federal Government Agency. Attachments that are part of this
> E-communication may have additional important disclosures and disclaimers,
> which you should read. This message is subject to terms available at the
> following link: http://www.ml.com/e-communications_terms/. By messaging
> with Merrill Lynch you consent to the foregoing.
> --------------------------------------------------------------------------
>
> ______________________________________________
> R-help@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<http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to