[R] frustration with ave()

Ed Hagen e.hagen at biologie.hu-berlin.de
Sat Sep 27 15:49:12 CEST 2003


Dear All,

I'm confused why I'm getting NA's in the output from ave() (at the end). Any 
help would be greatly appreciated.  I'm including the data in case that is where 
the problem lies:


 > f <- factor(FAMILYID)
 > bodyfat <- na.omit(data.frame(loessBODYFAT, f))
 > bodyfat$loessBODYFAT
   [1] -8.950153e-01 -9.175285e-01  3.174061e-01 -2.101260e-01  2.534174e-02
   [6]  1.846599e-01  8.322865e-01  1.348331e+00  1.241318e+00  1.634000e+00
  [11]  1.611048e+00  6.824926e-01  2.346168e+00  2.924673e-01  6.919381e-01
  [16]  3.142321e-01 -5.615214e-01  9.196103e-01 -1.290328e+00 -1.798727e+00
  [21] -1.011590e-01  7.051146e-01 -1.254440e+00  1.189397e+00 -7.017545e-01
  [26]  2.290020e-02 -1.451774e+00 -6.124868e-01 -4.780954e-01  3.237365e+00
  [31]  1.595977e+00  5.950309e-01 -4.699706e-01 -2.153001e-01 -3.248170e-01
  [36] -5.295042e-01  2.780444e-01 -5.878282e-01 -3.325859e-01 -7.690049e-02
  [41]  4.991054e-01 -4.410101e-01  9.133328e-01  1.429758e+00 -8.484772e-01
  [46] -1.004829e-01  1.769479e-01  3.892871e-01  7.209969e-01  3.759455e-01
  [51]  3.982560e-02 -1.702333e-01 -3.622422e-01 -2.893234e-01 -9.769459e-01
  [56] -1.935057e+00 -3.881132e-01 -1.037270e-02  2.561803e-01  3.884395e+00
  [61] -2.234557e-01 -6.893120e-01  3.531379e-01 -1.726464e+00  7.136614e-02
  [66] -4.278400e-01 -3.756271e-01  5.494344e-02  6.545344e-01  4.999740e-01
  [71]  4.911730e-01 -1.296921e-05  3.166220e+00  2.715371e-01 -6.104207e-01
  [76]  1.893740e+00  1.031131e+00 -5.917449e-01 -7.442768e-01  2.503388e+00
  [81] -4.087622e-01  4.399654e-01 -8.355297e-01  3.964619e-01  2.672100e-01
  [86] -3.927630e-01 -1.295004e+00 -1.874215e-01 -9.548985e-01 -1.366311e-01
  [91] -1.352021e+00 -9.658552e-01 -1.190914e+00 -1.910233e+00 -7.595405e-02
  [96] -1.648916e-01 -1.743877e-01 -1.234058e-01 -1.723277e+00 -7.316183e-01
[101] -8.062482e-01 -8.386729e-02  3.672521e-01 -7.525477e-01 -7.851946e-01
[106] -5.464147e-01 -1.454035e-01 -2.447245e-01 -4.732026e-01 -5.131587e-02
[111] -4.651404e-01  9.230189e-02  9.773851e-01  1.293947e-01 -3.261368e-01
[116] -1.671177e+00 -2.615938e-01  8.152311e-01  1.757506e-01  4.018943e-01
[121] -6.631180e-01 -1.839677e-01
 > bodyfat$f
   [1] 1  1  1  1  1  2  3  3  3  3  3  3  3  3  3  3  4  5  6  6  6  7  7
  [24] 7  7  8  9  9  9  9  9  9  9  9  9  9  9  10 10 10 11 11 11 11 12 12
  [47] 12 12 13 13 13 14 14 14 15 15 15 15 15 16 16 16 16 16 16 16 16 18 18
  [70] 18 18 20 21 21 22 22 22 23 23 23 23 23 25 25 25 30 30 30 31 31 31 31
  [93] 35 35 35 35 35 35 37 37 39 39 39 39 39 39 39 39 40 40 44 44 45 45 45
[116] 47 47 47 47 50 50 50
50 Levels: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 ... 50
 > ave(bodyfat$loessBODYFAT, bodyfat$f)
   [1] -3.359844e-01 -3.359844e-01 -3.359844e-01 -3.359844e-01 -3.359844e-01
   [6]  1.846599e-01  1.099428e+00  1.099428e+00  1.099428e+00  1.099428e+00
  [11]  1.099428e+00  1.099428e+00  1.099428e+00  1.099428e+00  1.099428e+00
  [16]  1.099428e+00 -5.615214e-01  9.196103e-01 -1.063405e+00 -1.063405e+00
  [21] -1.063405e+00 -1.542074e-02 -1.542074e-02 -1.542074e-02 -1.542074e-02
  [26]  2.290020e-02  1.476790e-01  1.476790e-01  1.476790e-01  1.476790e-01
  [31]  1.476790e-01  1.476790e-01  1.476790e-01  1.476790e-01  1.476790e-01
  [36]  1.476790e-01  1.476790e-01 -3.324382e-01 -3.324382e-01 -3.324382e-01
  [41]  6.002965e-01  6.002965e-01  6.002965e-01  6.002965e-01 -9.568124e-02
  [46] -9.568124e-02 -9.568124e-02 -9.568124e-02  3.789227e-01  3.789227e-01
  [51]  3.789227e-01 -2.739330e-01 -2.739330e-01 -2.739330e-01 -6.108618e-01
  [56] -6.108618e-01 -6.108618e-01 -6.108618e-01 -6.108618e-01  1.082750e-01
  [61]  1.082750e-01  1.082750e-01  1.082750e-01  1.082750e-01  1.082750e-01
  [66]  1.082750e-01  1.082750e-01 -1.296921e-05 -1.296921e-05 -1.296921e-05
  [71] -1.296921e-05  7.714833e-01  2.397139e-01  2.397139e-01 -5.728595e-02
  [76] -5.728595e-02 -5.728595e-02 -6.250627e-01 -6.250627e-01 -6.250627e-01
  [81] -6.250627e-01 -6.250627e-01 -6.066309e-01 -6.066309e-01 -6.066309e-01
  [86]  2.602143e-01  2.602143e-01  2.602143e-01 -2.354473e-01 -2.354473e-01
  [91] -2.354473e-01 -2.354473e-01            NA            NA            NA
  [96]            NA            NA            NA            NA            NA
[101]            NA            NA            NA            NA            NA
[106]            NA            NA            NA            NA            NA
[111]            NA            NA            NA            NA            NA
[116]            NA            NA            NA            NA            NA
[121]            NA            NA
 >

Thanks in advance,

Edward H. Hagen                  Institute for Theoretical Biology
phone: +49/30 2093-8649             Humboldt-Universität zu Berlin
fax:   +49/30 2093-8801                         Invalidenstraße 43
http://itb.biologie.hu-berlin.de/~hagen      10115 Berlin, Germany




More information about the R-help mailing list