[R] Odp: Loop overwrite and data output problems

Petr PIKAL petr.pikal at precheza.cz
Mon Mar 1 13:57:43 CET 2010


The data you put before was just those 98 rows.

> data=read.table("clipboard", header=T)
> data$ID2
 [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 
24 25
[26] 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 
49 50
[51] 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 
74 75
[76] 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
> length(data$ID2)
[1] 98

The values below get scrambled by mail client so better to put csv file.

Regards
Petr


r-help-bounces at r-project.org napsal dne 01.03.2010 12:57:29:

> 
> Hi Pter,
> 
> No doubt!
> 
> I have put a very short form of the data set on the email - it is 
basically
> 2 data points from each individual, which should be enough to get an 
idea of
> where I'm going wrong.....hopefully!
> 
> I can send this as a .csv if you prefer?
> 
> Cheers,
> 
> Ross
> 
> SITE_NAME   SITE   YEAR   NAME   DAY   ID2   n_DAY   BEH_T   BEH_F DATE  
MO_AIR_TEMP
> PRECIP_MM_DAY   DAY_PUPPED_EST   DAY_LEAVE_EST   PUP_AGE_EST
> NR   1   2007   A1   3   1   78   22   56   02/10/2007   12.16666667   0 
  -11  10   14
> NR   1   2007   A2   2   2   60   10   50   01/10/2007   11.47333333   0 
  -10  12   12
> NR   1   2007   D2   20   3   36   11   25   19/10/2007   11.40833333 0  
5   25   16
> NR   1   2007   D5   12   4   42   15   27   11/10/2007   11.06666667 4  
5   23   8
> NR   1   2007   E2   22   5   28   9   19   21/10/2007   11.56666667   0 
  8   24   15
> NR   1   2007   F10   14   6   33   4   29   13/10/2007   12.34545455 0  

> -12   15   26
> NR   1   2007   F4   9   7   60   4   56   08/10/2007   10.01333333   0  
8   27   2
> NR   1   2007   F8   9   8   60   23   37   08/10/2007   10.01333333   0 
  8   33   2
> NR   1   2007   G3   19   9   36   3   33   18/10/2007   11.09166667   0 
  12   30   8
> NR   1   2007   G4   12   10   42   5   37   11/10/2007   11.06666667 4  
10   26   3
> NR   1   2007   G5   9   11   12   3   9   08/10/2007   10.01333333   0  
9   26   1
> NR   1   2007   H1   19   12   35   9   26   18/10/2007   11.09166667 0  
10  30   10
> NR   1   2007   I1   29   13   36   9   27   28/10/2007   9.347222222 8  
12  31   18
> NR   1   2007   I4   17   14   36   5   31   16/10/2007   9.619444444 
9.5 
> 12   29   6
> NR   1   2007   J1   30   15   36   14   22   29/10/2007   6.538888889 8 
 
> 14   34   17
> NR   1   2007   J2   24   16   12   0   12   23/10/2007   11.81666667 2  
13  34   12
> NR   1   2007   K1   29   17   36   10   26   28/10/2007   9.347222222 8 
 
> 16   32   14
> NR   1   2007   K4   27   18   12   2   10   26/10/2007   10.525   13 16 
  34   12
> NR   1   2007   L1   18   19   36   13   23   17/10/2007   7.811111111 8 
  16   34   3
> NR   1   2007   L2   24   20   12   0   12   23/10/2007   11.81666667 2  
16   33   9
> NR   1   2007   M2   18   21   36   7   29   17/10/2007   7.811111111 8  
17   35   2
> NR   1   2007   M3   23   22   33   4   29   22/10/2007   11.65555556 14 
  17   35   7
> NR   1   2007   M4   18   23   25   5   20   17/10/2007   7.811111111 8  
17   35   2
> NR   1   2007   N1   19   24   36   4   32   18/10/2007   11.09166667 0  
18   36   2
> NR   1   2007   N4   29   25   36   4   32   28/10/2007   9.347222222 8  
18  30   12
> NR   1   2007   P1   20   26   18   7   11   19/10/2007   11.40833333 0  
20   38   1
> NR   1   2007   R1   32   27   36   3   33   31/10/2007   12.01111111 18 
 
> 23   41   10
> NR   1   2007   R4   31   28   36   11   25   30/10/2007   8.877777778 
4.5 
> 27   45   5
> NR   1   2007   S1   27   29   24   4   20   26/10/2007   10.525   13 24 
  42   4
> NR   1   2007   S4   27   30   24   5   19   26/10/2007   10.525   13 25 
  43   3
> NR   1   2008   A1   16   31   112   35   77   15/10/2008   9.05   2.7 1 
  19   16
> NR   1   2008   A2   3   32   114   34   80   02/10/2008   8.1   5.5 -15 
  4   18
> NR   1   2008   A3   3   33   73   6   67   02/10/2008   8.1   5.5   3 
21   1
> NR   1   2008   A4   9   34   107   15   92   08/10/2008   10.8   0   -6 
  12   15
> NR   1   2008   A5   5   35   16   8   8   04/10/2008   5.490909091 14.5 
  2   19   4
> NR   1   2008   B1   7   36   50   4   46   06/10/2008   10.52   0   4 
25   4
> NR   1   2008   C1   13   37   62   18   44   12/10/2008   10.97272727 
11.7 
> 4   24   10
> NR   1   2008   C3   18   38   111   18   93   17/10/2008   10.15   6.2  
4   25   15
> NR   1   2008   D1   21   39   115   29   86   20/10/2008   8.509090909  
2.1 
> 5   28   17
> NR   1   2008   F1   12   40   122   16   106   11/10/2008   11.01818182 
  5.58   31   5
> NR   1   2008   G1   17   41   39   11   28   16/10/2008   8.692307692 
0.7  9   29   9
> NR   1   2008   G2   16   42   115   29   86   15/10/2008   9.05   2.7 9 
  27   8
> NR   1   2008   H1   23   43   35   7   28   22/10/2008   9.733333333 
6.2 
> 10   27   14
> NR   1   2008   H2   14   44   115   24   91   13/10/2008   10.33870968  
0.7 
> 10   27   5
> NR   1   2008   I1   16   45   115   20   95   15/10/2008   9.05   2.7 
11   29   6
> NR   1   2008   I2   27   46   25   1   24   26/10/2008   6.055555556 0  
11  30   17
> NR   1   2008   I3   21   47   114   33   81   20/10/2008   8.509090909  
2.1 
> 10   30   12
> NR   1   2008   I4   15   48   30   4   26   14/10/2008   10.2   0   11  
33   5
> NR   1   2008   J1   17   49   33   2   31   16/10/2008   8.692307692 
0.7 
> 12   27   6
> NR   1   2008   J3   19   50   73   13   60   18/10/2008   8.272727273 
2.1 
> 12   31   8
> NR   1   2008   J4   13   51   67   14   53   12/10/2008   10.97272727 
11.7 
> 12   30   2
> NR   1   2008   J6   19   52   112   19   93   18/10/2008   8.272727273  
2.1 
> 12   28   8
> NR   1   2008   K1   21   53   115   15   100   20/10/2008   8.509090909 
  2.1
> 14   27   8
> NR   1   2008   K2   27   54   25   5   20   26/10/2008   6.055555556 0  
14  31   14
> NR   1   2008   K3   18   55   27   7   20   17/10/2008   10.15   6.2 14 
  33   5
> NR   1   2008   L2   15   56   48   9   39   14/10/2008   10.2   0   15  
33   1
> NR   1   2008   L4   28   57   85   35   50   27/10/2008   4.825   0 15  
30   14
> NR   1   2008   L5   28   58   85   24   61   27/10/2008   4.825   0 15  
33   14
> NR   1   2008   N1   25   59   91   21   70   24/10/2008   7.657142857 
11.7 
> 17   33   9
> NR   1   2008   N3   25   60   91   15   76   24/10/2008   7.657142857 
11.7 
> 17   35   9
> NR   1   2008   NNB   23   61   35   7   28   22/10/2008   9.733333333 
6.2 
> 18   36   6
> NR   1   2008   O1   23   62   8   4   4   22/10/2008   9.733333333 6.2  
18   36   6
> FA   0   2008   A10   5   63   92   30   62   23/11/2008   4.272727273 0 
  -8   8   13
> FA   0   2008   A11   5   64   13   11   2   23/11/2008   4.272727273 0  
-9   9   14
> FA   0   2008   A12   9   65   97   30   67   27/11/2008   7.832835821 0 
 
> -4   14   13
> FA   0   2008   A13   1   66   68   11   57   19/11/2008   12.28674699 0 
  -6   12   7
> FA   0   2008   A14   2   67   88   35   53   20/11/2008   9.609090909 0 
 
> -14   5   16
> FA   0   2008   A15   7   68   97   37   60   25/11/2008   5.081818182 
4.2 
> -3   15   10
> FA   0   2008   A16   3   69   97   12   85   21/11/2008   2.890909091 
2.8 
> -14   4   17
> FA   0   2008   A2   7   70   97   40   57   25/11/2008   5.081818182 
4.2 
> -11   8   18
> FA   0   2008   A3   7   71   97   16   81   25/11/2008   5.081818182 
4.2 
> -7   11   14
> FA   0   2008   A4   4   72   97   46   51   22/11/2008   2.009090909 2  
-10   9   14
> FA   0   2008   A5   2   73   88   23   65   20/11/2008   9.609090909 0  
-12   7   14
> FA   0   2008   A6   9   74   97   27   70   27/11/2008   7.832835821 0  
-4  14   13
> FA   0   2008   A7   10   75   51   18   33   28/11/2008   3.109090909 
0.2 
> -2   17   12
> FA   0   2008   A8   3   76   97   45   52   21/11/2008   2.890909091 
2.8 
> -10   9   13
> FA   0   2008   A9   9   77   5   4   1   27/11/2008   7.832835821   0 
-6   12   15
> FA   0   2008   B1   2   78   88   11   77   20/11/2008   9.609090909 0  
2   10   1
> FA   0   2008   B2   6   79   97   25   72   24/11/2008   6.066917293 
7.8   2   10   5
> FA   0   2008   C1   5   80   90   20   70   23/11/2008   4.272727273 0  
4   12   2
> FA   0   2008   C2   6   81   3   2   1   24/11/2008   6.066917293   7.8 
  4   12   3
> FA   0   2008   D1   9   82   97   34   63   27/11/2008   7.832835821 0  
5   13   5
> FA   0   2008   D2   10   83   48   20   28   28/11/2008   3.109090909 
0.2  5   13   6
> FA   0   2008   E1   9   84   97   26   71   27/11/2008   7.832835821 0  
6   14   4
> FA   0   2008   E2   7   85   97   32   65   25/11/2008   5.081818182 
4.2   6   14   2
> FA   0   2008   F1   8   86   95   39   56   26/11/2008   10.37938931 
0.2   7   15   2
> FA   0   2007   A1   5   87   36   19   17   23/11/2007   3.236363636 
5.8 
> -6   12   11
> FA   0   2007   B1   2   88   33   10   23   20/11/2007   8.981818182 
2.4 
> -1   17   3
> FA   0   2007   B13   6   89   48   19   29   24/11/2007   7.890909091 0 
 
> -11   8   17
> FA   0   2007   B2   10   90   18   6   12   28/11/2007   10.13636364 
0.6 
> -1   17   11
> FA   0   2007   B3   8   91   36   8   28   26/11/2007   4.872727273   0 
  -5   13   13
> FA   0   2007   B4   1   92   30   3   27   19/11/2007   8.45   3.8 -11  
8   12
> FA   0   2007   B6   5   93   36   9   27   23/11/2007   3.236363636 5.8 
  -2   16   7
> FA   0   2007   B7   1   94   30   9   21   19/11/2007   8.45   3.8   -5 
  13   6
> FA   0   2007   B8   1   95   30   3   27   19/11/2007   8.45   3.8   -4 
  14   5
> FA   0   2007   B9   1   96   30   5   25   19/11/2007   8.45   3.8   -6 
  12   7
> FA   0   2007   C1   4   97   36   10   26   22/11/2007   6.436363636 
0.2   3   21   2
> FA   0   2007   G1   10   98   9   1   8   28/11/2007   10.13636364 0.6  
5   23   6
> NR   1   2007   A1   5   1   66   23   43   04/10/2007   10.91515152   0 
  -11  10   16
> NR   1   2007   A2   9   2   56   8   48   08/10/2007   10.01333333   0  
-10   12   19
> NR   1   2007   D2   25   3   2   1   1   24/10/2007   11.16333333   0 5 
  25   21
> NR   1   2007   D5   13   4   48   10   38   12/10/2007   12.22916667 
4.5   5   23   9
> NR   1   2007   E2   23   5   36   11   25   22/10/2007   11.65555556 14 
  8  24   16
> NR   1   2007   F10   10   6   48   8   40   09/10/2007   10.98148148 0  

> -12   15   22
> NR   1   2007   F4   13   7   48   9   39   12/10/2007   12.22916667 4.5 
  8   27   6
> NR   1   2007   F8   25   8   30   3   27   24/10/2007   11.16333333   0 
  8   33   18
> NR   1   2007   G3   25   9   30   9   21   24/10/2007   11.16333333   0 
  12   30   14
> NR   1   2007   G4   25   10   30   8   22   24/10/2007   11.16333333 0  
10  26   16
> NR   1   2007   G5   16   11   34   2   32   15/10/2007   11.50833333 
3.5   9   26   8
> NR   1   2007   H1   16   12   36   8   28   15/10/2007   11.50833333 
3.5 
> 10   30   7
> NR   1   2007   I1   15   13   48   7   41   14/10/2007   12.05416667 17 
  12   31   4
> NR   1   2007   I4   13   14   48   3   45   12/10/2007   12.22916667 
4.5 
> 12   29   2
> NR   1   2007   J1   14   15   33   8   25   13/10/2007   12.34545455 0  
14   34   1
> NR   1   2007   J2   19   16   36   6   30   18/10/2007   11.09166667 0  
13   34   7
> NR   1   2007   K1   27   17   24   7   17   26/10/2007   10.525   13 16 
  32   12
> NR   1   2007   K4   28   18   35   3   32   27/10/2007   9.505555556 29 
 
> 16   34   13
> NR   1   2007   L1   25   19   30   11   19   24/10/2007   11.16333333 0 
 
> 16   34   10
> NR   1   2007   L2   32   20   36   4   32   31/10/2007   12.01111111 18 
 
> 16   33   17
> NR   1   2007   M2   18   21   36   7   29   17/10/2007   7.811111111 8  
17   35   2
> NR   1   2007   M3   18   22   36   11   25   17/10/2007   7.811111111 8 
  17   35   2
> NR   1   2007   M4   32   23   36   8   28   31/10/2007   12.01111111 18 
 
> 17   35   16
> NR   1   2007   N1   19   24   36   4   32   18/10/2007   11.09166667 0  
18   36   2
> NR   1   2007   N4   18   25   24   2   22   17/10/2007   7.811111111 8  
18   30   1
> NR   1   2007   P1   30   26   36   9   27   29/10/2007   6.538888889 8  
20  38   11
> NR   1   2007   R1   30   27   36   5   31   29/10/2007   6.538888889 8  
23   41   8
> NR   1   2007   R4   31   28   36   11   25   30/10/2007   8.877777778 
4.5 
> 27   45   5
> NR   1   2007   S1   27   29   24   4   20   26/10/2007   10.525   13 24 
  42   4
> NR   1   2007   S4   28   30   36   8   28   27/10/2007   9.505555556 29 
  25   43   4
> NR   1   2008   A1   5   31   61   12   49   04/10/2008   5.490909091 
14.5  1   19   5
> NR   1   2008   A2   3   32   114   34   80   02/10/2008   8.1   5.5 -15 
  4   18
> NR   1   2008   A3   4   33   26   2   24   03/10/2008   7   0   3   21  
2
> NR   1   2008   A4   3   34   112   18   94   02/10/2008   8.1   5.5 -6  
12   9
> NR   1   2008   A5   18   35   103   36   67   17/10/2008   10.15   6.2  
2   19   17
> NR   1   2008   B1   13   36   121   28   93   12/10/2008   10.97272727  
11.7
> 4   25   10
> NR   1   2008   C1   5   37   80   17   63   04/10/2008   5.490909091 
14.5  4   24   2
> NR   1   2008   C3   8   38   118   23   95   07/10/2008   11.68181818 
6.1  4   25   5
> NR   1   2008   D1   14   39   115   14   101   13/10/2008   10.33870968 
  0.7
> 5   28   10
> NR   1   2008   F1   24   40   91   21   70   23/10/2008   11.9   19.9 8 
  31   17
> NR   1   2008   G1   18   41   111   20   91   17/10/2008   10.15   6.2  
9   29   10
> NR   1   2008   G2   9   42   122   28   94   08/10/2008   10.8   0   9  
27   1
> NR   1   2008   H1   15   43   50   9   41   14/10/2008   10.2   0   10  
27   6
> NR   1   2008   H2   25   44   91   18   73   24/10/2008   7.657142857 
11.7 
> 10   27   16
> NR   1   2008   I1   15   45   50   15   35   14/10/2008   10.2   0   11 
  29   5
> NR   1   2008   I2   20   46   2   1   1   19/10/2008   11.85   9.6   11 
  30   10
> NR   1   2008   I3   11   47   121   18   103   10/10/2008   11.82307692 
  2.1
> 10   30   2
> NR   1   2008   I4   17   48   34   9   25   16/10/2008   8.692307692 
0.7 
> 11   33   7
> NR   1   2008   J1   20   49   44   2   42   19/10/2008   11.85   9.6 12 
  27   9
> NR   1   2008   J3   21   50   108   15   93   20/10/2008   8.509090909  
2.1 
> 12   31   10
> NR   1   2008   J4   14   51   44   2   42   13/10/2008   10.33870968 
0.7 
> 12   30   3
> NR   1   2008   J6   27   52   25   13   12   26/10/2008   6.055555556 0 
 
> 12   28   16
> NR   1   2008   K1   23   53   35   1   34   22/10/2008   9.733333333 
6.2 
> 14   27   10
> NR   1   2008   K2   20   54   41   12   29   19/10/2008   11.85   9.6 
14   31   7
> NR   1   2008   K3   25   55   91   11   80   24/10/2008   7.657142857 
11.7 
> 14   33   12
> NR   1   2008   L2   20   56   44   5   39   19/10/2008   11.85   9.6 15 
  33   6
> NR   1   2008   L4   19   57   112   23   89   18/10/2008   8.272727273  
2.1 
> 15   30   5
> NR   1   2008   L5   25   58   90   17   73   24/10/2008   7.657142857 
11.7 
> 15   33   11
> NR   1   2008   N1   21   59   115   19   96   20/10/2008   8.509090909  
2.1 
> 17   33   5
> NR   1   2008   N3   17   60   39   8   31   16/10/2008   8.692307692 
0.7 
> 17   35   1
> NR   1   2008   NNB   22   61   86   20   66   21/10/2008   5.41   3.4 
18   36   5
> NR   1   2008   O1   23   62   8   4   4   22/10/2008   9.733333333 6.2  
18   36   6
> FA   0   2008   A10   2   63   88   26   62   20/11/2008   9.609090909 0 
  -8   8   10
> FA   0   2008   A11   4   64   89   43   46   22/11/2008   2.009090909 2 
  -9   9   13
> FA   0   2008   A12   9   65   97   30   67   27/11/2008   7.832835821 0 
 
> -4   14   13
> FA   0   2008   A13   1   66   68   11   57   19/11/2008   12.28674699 0 
  -6   12   7
> FA   0   2008   A14   3   67   97   40   57   21/11/2008   2.890909091 
2.8 
> -14   5   17
> FA   0   2008   A15   2   68   88   27   61   20/11/2008   9.609090909 0 
  -3   15   5
> FA   0   2008   A16   2   69   78   16   62   20/11/2008   9.609090909 0 
 
> -14   4   16
> FA   0   2008   A2   3   70   97   47   50   21/11/2008   2.890909091 
2.8 
> -11   8   14
> FA   0   2008   A3   6   71   97   24   73   24/11/2008   6.066917293 
7.8 
> -7   11   13
> FA   0   2008   A4   6   72   97   30   67   24/11/2008   6.066917293 
7.8 
> -10   9   16
> FA   0   2008   A5   5   73   92   21   71   23/11/2008   4.272727273 0  
-12   7   17
> FA   0   2008   A6   1   74   87   9   78   19/11/2008   12.28674699   0 
  -4   14   5
> FA   0   2008   A7   7   75   94   14   80   25/11/2008   5.081818182 
4.2 
> -2   17   9
> FA   0   2008   A8   4   76   97   22   75   22/11/2008   2.009090909 2  
-10   9   14
> FA   0   2008   A9   4   77   97   29   68   22/11/2008   2.009090909 2  
-6  12   10
> FA   0   2008   B1   10   78   89   24   65   28/11/2008   3.109090909 
0.2  2   10   9
> FA   0   2008   B2   5   79   92   16   76   23/11/2008   4.272727273 0  
2   10   4
> FA   0   2008   C1   7   80   90   23   67   25/11/2008   5.081818182 
4.2   4   12   4
> FA   0   2008   C2   9   81   95   17   78   27/11/2008   7.832835821 0  
4   12   6
> FA   0   2008   D1   7   82   95   22   73   25/11/2008   5.081818182 
4.2   5   13   3
> FA   0   2008   D2   9   83   66   26   40   27/11/2008   7.832835821 0  
5   13   5
> FA   0   2008   E1   9   84   97   26   71   27/11/2008   7.832835821 0  
6   14   4
> FA   0   2008   E2   8   85   95   17   78   26/11/2008   10.37938931 
0.2   6   14   3
> FA   0   2008   F1   8   86   95   39   56   26/11/2008   10.37938931 
0.2   7   15   2
> FA   0   2007   A1   7   87   36   17   19   25/11/2007   5.718181818 
0.2 
> -6   12   13
> FA   0   2007   B1   8   88   36   15   21   26/11/2007   4.872727273 0  
-1   17   9
> FA   0   2007   B13   6   89   48   19   29   24/11/2007   7.890909091 0 
 
> -11   8   17
> FA   0   2007   B2   2   90   36   11   25   20/11/2007   8.981818182 
2.4 
> -1   17   3
> FA   0   2007   B3   5   91   36   7   29   23/11/2007   3.236363636 5.8 
 
> -5   13   10
> FA   0   2007   B4   7   92   35   11   24   25/11/2007   5.718181818 
0.2 
> -11   8   18
> FA   0   2007   B6   2   93   36   10   26   20/11/2007   8.981818182 
2.4 
> -2   16   4
> FA   0   2007   B7   1   94   30   9   21   19/11/2007   8.45   3.8   -5 
  13   6
> FA   0   2007   B8   3   95   30   10   20   21/11/2007   8.927272727 
11.8 
> -4   14   7
> FA   0   2007   B9   8   96   36   4   32   26/11/2007   4.872727273   0 
  -6   12   14
> FA   0   2007   C1   9   97   36   5   31   27/11/2007   7.945454545   0 
  3   21   7
> FA   0   2007   G1   7   98   36   6   30   25/11/2007   5.718181818 0.2 
  5   23   3
> -- 
> View this message in context: 
http://n4.nabble.com/Loop-overwrite-and-data-
> output-problems-tp1570593p1573461.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list