Re: [R] Converting a list from R to Stata

From: Thomas Lumley <tlumley_at_u.washington.edu>
Date: Thu 04 Aug 2005 - 01:38:44 EST

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



R-help@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 Received on Thu Aug 04 01:43:25 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 15:02:39 EST