[R] plotting multiple groups (newbie Q)

Sumitrajit Dhar s-dhar at northwestern.edu
Tue Oct 31 03:13:14 CET 2006


Hi Folks,

After loading a data set, I run the following:

 > kSum <- orderBy(~group,(summaryBy(DP_Level~F2 
+group,data=kdata,FUN=c(mean,sd),na.rm=T)))


kSum looks like this:

 > kSum
      F2 group DP_Level.mean DP_Level.sd
1   1.0     N   -1.55186475   11.022245
4   2.0     N   -2.48013300   10.624583
7   3.0     N  -12.47671250   11.104792
10  4.0     N  -13.72430950   12.000779
13  6.0     N  -20.33209750   11.393002
16  8.0     N  -26.09158500    6.851262
19 12.5     N  -25.17146000    5.480260
22 14.0     N  -26.11350500    6.012569
25 16.0     N  -25.77838600    6.186600
2   1.0    SN   -4.89147932   14.141263
5   2.0    SN  -13.11899886   11.457917
8   3.0    SN  -20.30688429    8.037245
11  4.0    SN  -27.95203107    7.337336
14  6.0    SN  -23.29571750    9.499774
17  8.0    SN  -25.60317143    7.292301
20 12.5    SN  -29.48492857    8.008832
23 14.0    SN  -25.12681071    5.811917
26 16.0    SN  -26.62930714    5.108508
3   1.0     Y    0.08977071    9.510582
6   2.0     Y   -2.13214786   13.840692
9   3.0     Y   -7.44449971   10.245682
12  4.0     Y   -6.42145271   17.000314
15  6.0     Y   -2.10020521   16.730351
18  8.0     Y   -7.88271257   19.726457
21 12.5     Y  -24.26840000    7.275585
24 14.0     Y  -22.18628571    2.878094
27 16.0     Y  -24.74949286    6.556951

Now I want to do some plotting:

 > plot(kSum$F2[group=="N"],kSum$DP_Level.mean[group=="N"],type="l")
# This works fine
 > plot(kSum$F2[group=="SN"],kSum$DP_Level.mean[group=="SN"],type="l")
# This plots both "N" and "SN" in one line sequentially
 > plot(kSum$F2[group=="Y"],kSum$DP_Level.mean[group=="Y"],type="l")
# This gives the following error messages.
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

What am I doing wrong? All suggestions are appreciated.

Regards,
Sumit



More information about the R-help mailing list