[R] struggling to plot subgroups

Michael Dewey info at aghmed.fsnet.co.uk
Sun Nov 5 12:11:16 CET 2006


At 04:06 05/11/2006, Sumitrajit Dhar wrote:
>Hi Folks,
>
>I have data that looks like this:
>
>freq            gender          xBar
>1000    m                       2.32
>1000    f                       3.22
>2000    m                       4.32
>2000    f                       4.53
>3000    m                       3.21
>3000    f                       3.44
>4000    m                       4.11
>4000    f                       3.99
>
>I want to plot two lines (with symbols) for the two groups "m" and
>"f". I have tried the following:
>
>plot(xBar[gender=="m"]~freq[gender=="f"]) followed by

So you want to plot the value of xBar for a man against the 
corresponding freq for a woman? But how are we to tell which man maps 
to which woman?


>lines(xBar[gender=="m"]~freq[gender=="f"])
>
>with different symbols and lines colors (which I know how to do).
>
>However, these initial plots are not giving me the right output. The
>initial plot command generates the following error.
>Error in plot.window(xlim, ylim, log, asp, ...) :
>         need finite 'xlim' values
>In addition: Warning messages:
>1: no non-missing arguments to min; returning Inf
>2: no non-missing arguments to max; returning -Inf
>3: no non-missing arguments to min; returning Inf
>4: no non-missing arguments to max; returning -Inf
>
>A second issue, I would also like to offset the second set of points
>along the x-axis so that the error bars will be visible.
>
>Any help is appreciated.
>
>Regards,
>Sumit
>
>

Michael Dewey
http://www.aghmed.fsnet.co.uk



More information about the R-help mailing list