[R] Split a vector(list) into 3 list

Leeds, Mark (IED) Mark.Leeds at morganstanley.com
Fri May 18 02:48:14 CEST 2007


index is definitely defined in my version ( 2.4.0) because when I do
?index, I get info. Maybe you
Are using an older or younger version of R ? I'm really not sure why you
are experiencing that problem.


-----Original Message-----
From: Patrick Wang [mailto:pwang at berkeley.edu] 
Sent: Thursday, May 17, 2007 8:44 PM
To: Leeds, Mark (IED)
Cc: Patrick Wang; r-help at stat.math.ethz.ch
Subject: RE: [R] Split a vector(list) into 3 list

Thanks,

no index function was defined in R.

I try to use the split(order(temp), temp), the number of groups are
correct, however the result doesnot seem to be correct. I try to match
before the ordered index and the original index.

Pat

> If  temp is your vector then split(index(temp),temp) will give you 
> what you want.
>
>
> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch 
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Patrick Wang
> Sent: Thursday, May 17, 2007 8:15 PM
> To: r-help at stat.math.ethz.ch
> Subject: [R] Split a vector(list) into 3 list
>
> Hi,
>
> I have a vector contains values 1,2,3.
>
> Can I call a function split to split it into 3 vectors with 1 
> corresponds to value ==1, which contain all the indexes for value==1.
>
> 2 corresponds to value ==2 which contain all the indexes for value=2
>
> Thanks
> pat
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
> --------------------------------------------------------
>
> This is not an offer (or solicitation of an offer) to buy/sell the 
> securities/instruments mentioned or an official confirmation.  Morgan 
> Stanley may deal as principal in or own or act as market maker for 
> securities/instruments mentioned or may advise the issuers.  This is 
> not research and is not from MS Research but it may refer to a 
> research analyst/research report.  Unless indicated, these views are 
> the author's and may differ from those of Morgan Stanley research or 
> others in the Firm.  We do not represent this is accurate or complete 
> and we may not update this.  Past performance is not indicative of 
> future returns.  For additional information, research reports and 
> important disclosures, contact me or see 
> https://secure.ms.com/servlet/cls.  You should not use e-mail to 
> request, authorize or effect the purchase or sale of any security or 
> instrument, to send transfer instructions, or to effect any other 
> transactions.  We cannot guarantee that any such requests received via

> e-mail will be processed in a timely manner.  This communication is 
> solely for the addressee(s) and may contain confidential information.

> We do not waive confidentiality by mistransmission.  Contact me if you

> do not wish to receive these communications.  In the UK, this 
> communication is directed in the UK to those persons who are market 
> counterparties or intermediate customers (as defined in the UK
Financial Services Authority's rules).
>
--------------------------------------------------------

This is not an offer (or solicitation of an offer) to buy/se...{{dropped}}



More information about the R-help mailing list