Re: [R] replicating dataframe rows

2008-09-29 Thread David Huffer
On Monday, September 29, 2008 1:59, Dimitris Rizopoulos wrote: > On Monday, September 29, 2008 1:26, milton ruser wrote: > > ...I have a data.frame like... > >place<-c("place1", "place2", "place3", "place4", "place5") > >population<-c(100,200,300,50,30) > >my.df<-data.frame(cbi

Re: [R] replicating dataframe rows

2008-09-29 Thread Dimitris Rizopoulos
try this: place <- c("place1", "place2", "place3", "place4", "place5") population <- c(100, 200, 300, 50, 30) my.df <- data.frame(place, population) my.df[rep(row.names(my.df), my.df$population), ] I hope it helps. Best, Dimitris milton ruser wrote: Dear all, I have a data.frame like the

Re: [R] replicating dataframe rows

2008-09-29 Thread Henrique Dallazuanna
Try this: my.df <- data.frame(Place = rep(place, population), Population = rep(population, population)) On Mon, Sep 29, 2008 at 2:26 PM, milton ruser <[EMAIL PROTECTED]> wrote: > Dear all, > > I have a data.frame like the sample below, and I would > like to expand my data.frame using "population"

[R] replicating dataframe rows

2008-09-29 Thread milton ruser
Dear all, I have a data.frame like the sample below, and I would like to expand my data.frame using "population" variable. So, for each line of my data.frame I would like that the new data.frame have many rows as the population collumn. place<-c("place1", "place2", "place3", "place4", "place5") p