Vonton
Vonton

Reputation: 3372

Average between elements in R of list

I would like to gt average value for the elements on specific position in list. Please could you help me?

I have a list file of elements:

> [[1]] [1] 53 53 53 53 41 53 59 59 51 53 53 53 53 53 53 53 53 36 53 53
> 47 53 53 47 53
> 
> [[2]] [1] 53 53 53 47 53 59 60 59 59 60 60 54 60 59 59 59 45 56 56 55
> 55 41 53
> 
> [[3]] [1] 61 61 64 61 66 64 61 60 60 60 60 59 56 56 56 56 42 53 58 58
> 58 63 52 63 55

And I would like to get vector of numbers with average values:

> [1] 55.67 55.67 ....

Count of element is not same..

Could you help me please? Thank you so much..

Upvotes: 0

Views: 6815

Answers (1)

Antares42
Antares42

Reputation: 1436

You should use the sapplyfunction:

sapply(yourList,mean)

Upvotes: 1

Related Questions