[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Robert A Yaffee <bob.yaffee@nyu.edu> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Stata and R |

Date |
Tue, 25 Aug 2009 23:09:46 -0400 |

Hi Frank, In R or S+, length refers to the number of observations in a time series dataset. Therefore, were we to use Cobb's dataset of the Nile River discharge flow measured at the Aswan Dam, which contains 100 annual observations, the length(Nile) would = 100. In Stata, this would be found with the command, display _N The subset command in R allows you to extract a subset of variables from a dataset. The command can also be applied to matrices to subset out a number of columns. It can also be applied to vectors to obtain subsets of them. In Stata, this data subset extraction could be accomplished with the keep <varlist> or drop <varlist> command. Stata tries to make such subsetting simpler and more user friendly. -Bob Robert A. Yaffee, Ph.D. Research Professor Silver School of Social Work New York University Biosketch: http://homepages.nyu.edu/~ray1/Biosketch2009.pdf CV: http://homepages.nyu.edu/~ray1/vita.pdf ----- Original Message ----- From: Tirthankar Chakravarty <tirthankar.chakravarty@gmail.com> Date: Tuesday, August 25, 2009 12:36 pm Subject: Re: st: Stata and R To: statalist@hsphsun2.harvard.edu > The Mata functions -select()- and -length()- are closest in spirit. > For example: > ********************************* > sysuse auto, clear > mata > st_view(X=.,., ("price", "mpg", "weight", "length")) > Y = select(X, X[., 1]:>mean(X[.,1])) > length(Y) > end > ********************************* > keeps the rows of the data matrix for which the price of the car is > greater than the mean. > > T > > On Tue, Aug 25, 2009 at 5:12 PM, Frank Peter<frankpeter@safe-mail.net> > wrote: > > Dear Statalister, > > > > Please, I am new to Stata, I am trying to replicate some R commands > in Stata. I will like to know the equivalent of length and subset in Stata. > > > > Thanks. > > > > Frank > > * > > * For searches and help try: > > * http://www.stata.com/help.cgi?search > > * http://www.stata.com/support/statalist/faq > > * http://www.ats.ucla.edu/stat/stata/ > > > > > > -- > To every ω-consistent recursive class κ of formulae there correspond > recursive class signs r, such that neither v Gen r nor Neg(v Gen r) > belongs to Flg(κ) (where v is the free variable of r). > > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/statalist/faq > * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**RE: st: Stata and R***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**References**:**st: Stata and R***From:*"Frank Peter" <frankpeter@Safe-mail.net>

**Re: st: Stata and R***From:*Tirthankar Chakravarty <tirthankar.chakravarty@gmail.com>

- Prev by Date:
**st: set memory question** - Next by Date:
**Re: st: set memory question** - Previous by thread:
**Re: st: Stata and R** - Next by thread:
**RE: st: Stata and R** - Index(es):

© Copyright 1996–2016 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |