[R] vector distribution
bolker at ufl.edu
Tue Dec 25 03:55:21 CET 2007
-Halcyon- <Cyonora <at> gmail.com> writes:
> Hi everyone,
> say i have a population (stable) with different amounts of animals in every
> ageclass (80 of age 1, 60 of age 2, etc) in a vector.
> Can anybody tell me how i can add gender (male or female) to all ageclasses?
> I want a 1:1 ratio of males and females within the population (as a starting
> value). So, 40 males and 40 females of age 1, 30m-30f of age 2, etc etc...
> Any help would be greatly appreciated!!
> Kind regards
Do you mean something like
> x <- c(age1=80,age2=60,age3=40)
age1 age2 age3
80 60 40
> y <- rep(x/2,2)
> names(y) <- c(paste("M",names(x),sep="."),paste("F",names(x),sep="."))
M.age1 M.age2 M.age3 F.age1 F.age2 F.age3
40 30 20 40 30 20
More information about the R-help