Thank you for your help. Appreciate it a lot! I am using appropriate names,
just here as an example I used data :)





2013/5/15 Rui Barradas <ruipbarra...@sapo.pt>

> Hello,
>
> Try the following.
>
> aggregate(. ~ interval, data = data, mean)
>
>
> Also, 'data' is an R function, you should use some other name, such as
> 'dat'.
>
> Hope this helps,
>
> Rui Barradas
>
> Em 15-05-2013 10:46, Simonas Kecorius escreveu:
>
>  Dear R users,
>>
>> Here is my data:
>>
>> "a1"    "a2"    "a3"    "a4"    "a5"    "interval"
>> 432    355    159    9304    9949    1
>> 0    184    157    9182    10120    1
>> 1295    2    0    8861    10410    1
>> 0    100    572    9102    9836    1
>> 0    170    95    8421    9044    1
>> 0    170    2    8963    9261    1
>> 0    723    380    8483    8923    2
>> 0    184    111    8206    9373    2
>> 0    539    223    8670    8714    2
>> 0    341    4    8044    7977    2
>> 432    403    412    6938    7755    2
>> 0    218    395    7661    7898    2
>> 432    67    428    7176    7957    3
>> 0    0    47    7508    8160    3
>> 0    67    382    6978    7811    3
>> 0    0    47    8537    8486    3
>> 0    605    698    8651    9421    3
>> 432    1    0    8114    8923    3
>> 0    204    193    8904    9324    4
>> 432    1221    371    8997    9681    4
>> 0    0    0    8454    8838    4
>> 0    170    49    8232    8994    4
>> 0    184    111    9251    10790    4
>> 0    170    142    8227    9616    4
>> 0    67    428    8147    8359    5
>> 864    356    112    8570    8578    5
>> 0    0    47    8285    8859    5
>> 432    67    475    8326    8915    5
>> 432    355    112    8379    9061    5
>> 1296    513    52    8041    9023    5
>> 0    369    221    8253    9262    6
>> 432    402    412    8840    8704    6
>> 0    184    111    9085    9718    6
>> 0    170    2    8381    9335    6
>> 432    34    285    8744    8999    6
>> 0    355    159    8564    9387    6
>> 863    526    114    8479    10050    7
>> 432    374    194    8130    7840    7
>> 0    355    159    7785    8728    7
>> 432    271    714    9065    9168    7
>> 432    67    428    8621    9906    7
>> 0    639    795    8294    8697    7
>> 432    185    204    9243    9206    8
>> 0    388    303    8938    9789    8
>> 0    756    571    9574    9090    8
>> 432    67    522    8733    8931    8
>> 864    205    286    7760    8340    8
>> 0    170    95    8089    8597    8
>> 432    34    284    8132    8702    9
>> 0    100    666    7704    8686    9
>> 432    526    114    7414    8370    9
>> 0    170    142    8039    8385    9
>> 0    606    698    8443    9366    9
>> 432    67    428    9334    9000    9
>> 0    184    111    8313    8312    10
>> 432    696    303    8280    8597    10
>> 0    0    0    8578    9124    10
>> 0    170    2    7820    9355    10
>> 0    0    0    7738    7975    10
>> 0    184    157    8867    8843    10
>> 432    34    191    7664    8629    11
>> 0    0    94    8368    9230    11
>> 432    403    506    8601    9095    11
>> 0    0    0    9330    8670    11
>> 0    341    50    8782    8562    11
>> 0    0    0    7676    8191    11
>> 432    355    253    7033    8274    12
>> 2159    1214    1302    8068    8903    12
>> 432    1901    1679    8230    9152    12
>> 864    1567    1368    8813    8729    12
>> 863    1382    1398    8329    9207    12
>> 432    1282    779    8162    8644    12
>> 2160    1811    2099    8465    7745    13
>> 3456    394    444    8263    8833    13
>> 432    843    1034    8195    8508    13
>> 0    828    1066    7338    7591    13
>> 863    743    509    8134    8734    13
>> 2159    581    480    7325    8426    13
>> 0    979    799    7999    8233    14
>> 864    783    626    8337    9256    14
>> 1727    2210    1680    7633    8735    14
>> 1728    2427    3859    8248    8895    14
>> 5616    3623    3227    7566    8268    14
>> 4318    2887    2478    7520    8146    14
>>
>> I read it from a file:
>>
>> data<-read.table("data.txt", head=T, sep="\t")
>>
>> When I try count column mean by interval:
>>
>> newData <- do.call(rbind, tapply(data[1:5], data$interval, colMeans))
>>
>>
>> I get an error: Error in tapply(data[1:5], data$interval, colMeans) :
>>    arguments must have same length
>>
>> Has anyone any clue what is wrong?
>> Thank you in advance.
>>
>>


-- 
Simonas Kecorius
**

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to