0

I have a list called "y"

> y
> 
> $a  [1] 1710  934  800  637  588  951 2312 3769 3348 2788 2879 3318
> 3713 4102 4333 [16] 4583 4614 4367 4040 3766 3443 2793 2439 2134 1317 
> 759  727  660
> 
> $b  [1]  664  912 2266 3685 3502 2772 2704 3224 3688 4078 3936 4249
> 4497 4399 4330 [16] 3972 3378 2918 2433 2563 2519  989  790  702  581 
> 884 2262 3599
> 
> $c  [1] 3393 2669 2751 3213 3668 4064 3882 4533 4648 4318 4233 4122
> 3752 3418 2753 [16] 2525 1929 1030  859  663  660  898 2217 3696 3380
> 2567 2640 3253
> 
> $d  [1] 3881 4060 4229 4376 4632 4440 4279 4058 3666 3743 3116 3153
> 2035 1082  873 [16]  715  762  975 2277 3507 3450
> 
> $e  [1] 2785 2894 3309 3858 4264 4430 4532 4576 4250 4442 4176 4267
> 3375 3275 3357 [16] 2911 1901 1634 1259 1073 1005
> 
> $f  [1] 1233 1713 2105 2372 2915 3822 3895 4069 3937 4124 3858 3756
> 3386 3109 1765 [16] 2075 2377 1738  797  447 1095
> 
> $g  [1]  944  724  651  567  591  840 1351 1812 2130 2292 2538 2403
> 2405 2970 2768 [16] 2792 3299 3265 3016 2778 2748

and need to know how can I compute the mean for each group in the list.

I tried mean(y) but it didn't work. I tried also mean mean(y[1:7]) but It didn't work, please help me

d.b
  • 32,245
  • 6
  • 36
  • 77
Michael Spector
  • 113
  • 1
  • 7

1 Answers1

1

You may try using lapply as follows:

y <- list(a=1:3, b=4:6)
lapply(y, mean)
Noha Elprince
  • 1,924
  • 1
  • 16
  • 10