Re: [R] create multiple variables loop

2011-07-17 Thread Joshua Wiley
Hi Carlos, Assuming your actual dataset has as nice a structure as your example one, it is extremely easy: ## Your data (in convenient form using dput(df)) df <- structure(list(male1990 = c(10L, 23L, 32L), male1995 = c(11L, 22L, 33L), male2000 = c(15L, 25L, 37L), male2005 = c(17L, 28L, 36L), fem

[R] create multiple variables loop

2011-07-17 Thread jour4life
Hello all, I am trying to figure out how to construct several new variables without having to write a code for each one. Specifically, I want to calculate ratios for several variables. For instance, let's say I have: df male1990 male1995 male2000 male2005 female1990 female1995 female2000 female2