[R] Put one random row dataset to first cell variable

Jan Sabee jan.sabee at gmail.com
Wed Apr 20 10:46:11 CEST 2005


Dear useR help,
This is below my toy dataset,

   age married income gender
 young      no    low female
   old     yes    low female
   mid      no   high female
 young     yes   high female
   mid     yes   high female
   mid      no medium female
   old      no medium female
 young     yes medium female
   mid     yes    low   male
   old     yes    low   male
 young      no   high   male
   old      no   high   male
   mid     yes   high   male
 young     yes medium   male
   old     yes medium   male

and I take one random row (young,no,low,female) then I make like this
 
  age       <- c("young","mid","old")
  married   <- c("no","yes")
  income    <- c("low","high","medium")
  gender    <- c("female","male")

then I take one random row again (mid,yes,high,male), now

  age       <- c("mid","young","old")
  married   <- c("yes","no")
  income    <- c("high","low","medium")
  gender    <- c("male","female")

and etc, each I take one random row I put in the first cell in each
own variable.
Is this possible to make a simple function?

Sincerely,
Jan Sabee




More information about the R-help mailing list