[R] stripchart problem
paradis@univ-montp2.fr
paradis at univ-montp2.fr
Mon Dec 8 17:54:29 CET 2003
> Hello,
>
> I am trying to plot age distribution data for a certain condition that
> runs in families. Below is a simplified view of the dataset, i.e. in
> this case there are four families, each line corresponding to one
> individual with age at diagnosis and sex.
>
> > famdata
> family age sex
> 1 fam1 2.1 f
> 2 fam1 2.3 f
> 3 fam1 1.0 m
> 4 fam2 7.3 f
> 5 fam2 4.1 f
> 6 fam2 1.2 f
> 7 fam2 0.6 m
> 8 fam3 3.5 m
> 9 fam3 2.5 m
> 10 fam3 2.9 m
> 11 fam3 5.6 m
> 12 fam3 4.4 f
> 13 fam10 1.1 f
> 14 fam10 1.2 f
> 15 fam10 2.9 f
> 16 fam10 2.2 f
> 17 fam10 4.7 m
>
> I can nicely plot the age distribution by families with
>
> > stripchart(famdata$age~famdata$family)
>
> I would like to plot datapoints according to the sex of the person, e.g.
> circle for a girl and square for a boy, like this:
>
> > stripchart(famdata$age~famdata$family, pch=ifelse(famdata$sex=="m",
> 22, 1))
Try this:
stripchart(famdata$age ~ famdata$family, pch = c(1, 22)[unclass(famdata$sex)])
(maybe you need to have "c(22, 1)")
HTH
Emmanuel Paradis
>
> But this command doesn't work as I expected. Datapoints from fam2 are
> shown as squares, all the rest as circles. Still , this seems OK:
>
> > ifelse(famdata$sex=="m", 22, 1)
> [1] 1 1 22 1 1 1 22 22 22 22 22 1 1 1 1 1 22
>
> Any clues ?
>
> Thanks a lot for your help,
>
> alex
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>
More information about the R-help
mailing list