[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Stata and R
Robert A Yaffee <firstname.lastname@example.org>
Re: st: Stata and R
Tue, 25 Aug 2009 23:09:46 -0400
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.
Robert A. Yaffee, Ph.D.
Silver School of Social Work
New York University
----- Original Message -----
From: Tirthankar Chakravarty <email@example.com>
Date: Tuesday, August 25, 2009 12:36 pm
Subject: Re: st: Stata and R
> The Mata functions -select()- and -length()- are closest in spirit.
> For example:
> sysuse auto, clear
> st_view(X=.,., ("price", "mpg", "weight", "length"))
> Y = select(X, X[., 1]:>mean(X[.,1]))
> keeps the rows of the data matrix for which the price of the car is
> greater than the mean.
> On Tue, Aug 25, 2009 at 5:12 PM, Frank Peter<firstname.lastname@example.org>
> > 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: