Re: [R] How to make combination data

From: Jan Sabee <jan.sabee_at_gmail.com>
Date: Wed 20 Apr 2005 - 04:09:23 EST

Thanks you very much.
Yes, this is exactly what I want.

Best wishes,
Jan Sabee

On 4/19/05, Liaw, Andy <andy_liaw@merck.com> wrote:
> Is something like this what you're looking for?
>
> fixSome <- function(..., fixed) {
> fList <- list(...)
> for (i in fixed) fList[[i]] <- fList[[i]][1]
> do.call("expand.grid", fList)
> }
>
> > age <- c("young","mid","old")
> > married <- c("no","yes")
> > income <- c("low","high","medium")
> > gender <- c("female","male")
> >
> > age.income.dat <- fixSome(age, married, income, gender, fixed=c(2, 4))
> > age.income.dat
> Var1 Var2 Var3 Var4
> 1 young no low female
> 2 mid no low female
> 3 old no low female
> 4 young no high female
> 5 mid no high female
> 6 old no high female
> 7 young no medium female
> 8 mid no medium female
> 9 old no medium female
>
> Andy



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 Wed Apr 20 08:15:06 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:17 EST