[R] expand only one of variable

2006-06-08 Thread Muhammad Subianto
Dear all, I want to expand only one of variable in data frame and the others variable will be following with the expand variable. Here my toy example: toy.df - data.frame(size=c(3,1,2,0,3,5,1,0), group=LETTERS[1:8], country=c(Germany,England,Argentina,Mexico,Italy,Brazil,France,Spain),

Re: [R] expand only one of variable

2006-06-08 Thread Jacques VESLOT
toy.df$sign - ifelse(toy.df$size == 0, negative, positive) toy.df[rep(1:nrow(toy.df), ifelse(toy.df$size==0, 1, toy.df$size)),] --- Jacques VESLOT CNRS UMR 8090 I.B.L (2ème étage) 1 rue du Professeur Calmette B.P. 245 59019