Re: [R] Creating subsets of a matrix

2011-01-23 Thread poolmunch
# 4 . (a) Create subvectors, one for boys and one for girls. bmi.male <- subset(bmi, gender == "male") # Creates a subset of bmi with male only values n=30 bmi.female <- subset(bmi, gender == "female") # Creates a subset of bmi with female only values n=30 male.bmi.only <-(bmi.m

Re: [R] Creating subsets of a matrix

2011-01-23 Thread jim holtman
Try 'split' > x bmi gender 1 24.78 male 2 26.42 male 3 23.18 female 4 22.36 female > # create a list with the split genders > split(x, x$gender) $female bmi gender 3 23.18 female 4 22.36 female $male bmi gender 1 24.78 male 2 26.42 male > > On Sun, Jan 23, 2011 at 1:36 PM,

Re: [R] Creating subsets of a matrix

2011-01-23 Thread Joshua Wiley
Hi, Try looking at ?subset I think something like this should work: dat.male <- subset(dat, gender == "male") dat.female <- subset(dat, gender == "female") though it may require tweaking depending how your data is stored. If you want more specific help, suppose your matrix is called "dat" (but

[R] Creating subsets of a matrix

2011-01-23 Thread poolmunch
Hello, Say I have 2 columns, bmi and gender, the first being all the values and the second being male or female. How would I subset this into males only and females only? I have searched these fora and read endlessly about select[] and split() functions but to no avail. Also the table is not ord