[R] What is cast telling me?

rmailbox at justemail.net rmailbox at justemail.net
Wed Jul 8 21:58:38 CEST 2009


That you have non-unique rows in your data (as identified by the identifying variables).



----- Original message -----
From: "Mark Knecht" <markknecht at gmail.com>
To: "r-help" <r-help at r-project.org>
Date: Wed, 8 Jul 2009 12:41:28 -0700
Subject: [R] What is cast telling me?

Hi,
   What is cast telling me when it says the following?

Aggregation requires fun.aggregate: length used as default

What is 'length'?

   I've taken a small subset of data and wondered what EnTime vs
ExTime might look like. cast is kind enough to give me a table but I
don't understand the values in the table. They seem to sum up ro be
the same as the total dimension of the data so I'm guessing (but
cannot prove) that it's something like whether each experiment has
values for both EnTime and ExTime?

   Assuming that cast is taking some sort of sum then I'd like to
learn how to replace the value in the table with something meaningful
to me. On thing would the the ExNum value from the first occurrence at
that crosspoint, or the PL_Pos value, etc.

   How might I write a fun.aggregate to to that?

Thanks,
Mark

> dim(MyResults)
[1] 1105   12
> head(MyResults, n=15)
     ExNum PosType  EnDate EnTime  ExDate ExTime PL_Pos Costs Save2
time value id
1.1      1      -1 1080103    800 1080103   1310    520    26     0
1 746.2  1
2.1      2      -1 1080104    755 1080104   1310    530    26     0
1 721.9  2
3.1      3       1 1080107    945 1080107   1310   -340    26     0
1 722.8  3
4.1      4      -1 1080108    820 1080108   1310   2150    26     0
1 717.4  4
5.1      5      -1 1080109    855 1080109   1245  -1040    26     0
1 693.2  5
6.1      6       1 1080109   1245 1080109   1310    110    26     0
1 703.6  6
7.1      7       1 1080110    925 1080110   1310    680    26     0
1 708.9  7
8.1      8       1 1080111    800 1080111   1155   -830    26     0
1 709.4  8
9.1      9      -1 1080111   1155 1080111   1310    160    26     0
1 701.1  9
10.1    10      -1 1080114    935 1080114   1210   -810    26     0
1 698.9 10
11.1    11       1 1080114   1210 1080114   1310   -280    26     0
1 707.0 11
12.1    12      -1 1080115    750 1080115   1310   -310    26     0
1 688.2 12
13.1    13      -1 1080116    755 1080116    950  -1340    26     0
1 684.1 13
14.1    14       1 1080116    950 1080116   1310   -550    26     0
1 697.5 14
15.1    15      -1 1080117    740 1080117   1310    700    26     0
1 680.8 15
> cast(MyResults,ExTime ~ EnTime)
Aggregation requires fun.aggregate: length used as default
  ExTime 740 750 755 800 805 810 815 820 850 855 925 935 945 950 1125
1155 1210 1245 1305
1    950   0   0  25   0   0   0   0   0   0   0   0   0   0   0    0
  0    0    0    0
2   1125   0   0   0   0   0   0   0   0  33   0   0   0   0   0    0
  0    0    0    0
3   1155   0   0   0  49   0   0   0   0   0   0   0   0   0   0    0
  0    0    0    0
4   1210   0   0   0   0   0   0   0   0   0   0   0  33   0   0    0
  0    0    0    0
5   1245   0   0   0   0   0   0   0   0   0  48   0   0   0   0    0
  0    0    0    0
6   1305   0   0   0   0   0   0   0   0   0   0   0   0   0   0   22
  0    0    0    0
7   1310 136 132 130  64  63  62  61  60   0   0  47   0  43  42    0
 17   28    7    3
>
> sum(cast(MyResults,ExTime ~ EnTime))
Aggregation requires fun.aggregate: length used as default
[1] 1105
>

______________________________________________
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