[R] Converting a list from R to Stata

Thomas Lumley tlumley at u.washington.edu
Wed Aug 3 17:38:44 CEST 2005


On Wed, 3 Aug 2005, Vicky Landsman wrote:

>
> Dear all,
> I have a list containing 150 simulated datasets in R. Is there a way to
> convert it to the Stata format such that I will be able to apply some Stata
> functions on each dataset in the list?

For Stata your best best is probably to stack all 150 datasets into one 
long data frame and add an id variable, so you can then -by id:- your 
analysis.
   big.data.frame <- do.call("rbind", the.list.of.datasets)
will stack them for you and
   big.data.frame$id <- rep(1:150, sapply(the.list.of.data.sets, nrow))
will make the id variable.

 	-thomas




More information about the R-help mailing list