Statalist


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

Re: st: Stata and R


From   Robert A Yaffee <[email protected]>
To   [email protected]
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 <[email protected]>
Date: Tuesday, August 25, 2009 12:36 pm
Subject: Re: st: Stata and R
To: [email protected]


> 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<[email protected]> 
> 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/



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