Programming :  Student Freelance Forum For Work Experience Builders' (CertificationPoint) The fastest message board... ever.
 
Mean of an element in list of lists in R
Posted by: adcertpoint (Moderator)
Date: July 22, 2021 07:18PM

I have a list of lists, where in each list, there are tickers and their values. These tickers stay the same for each list but the values differ. Now, I want to see what is the average value of each of these tickers. The issue is that I don't know how to specify to look into a specific ticker in each list and extract the value. For instance, I want the mean value of "jpm" within this 3 lists. How can I do so? Thanks.

What I have so far:

dput(degree.l)
list(c(schwab = 0, pnc = 0.0344827586206897, jpm = 0.0862068965517241,
amex = 0.0862068965517241, gs = 0.103448275862069, ms = 0.103448275862069,
bofa = 0.103448275862069, citi = 0.103448275862069, wf = 0.120689655172414,
spgl = 0.120689655172414, brk = 0.137931034482759), c(schwab = 0.0166666666666667,
pnc = 0.05, ms = 0.0666666666666667, spgl = 0.0833333333333333,
jpm = 0.1, bofa = 0.1, wf = 0.1, amex = 0.1, gs = 0.116666666666667,
brk = 0.116666666666667, citi = 0.15), c(schwab = 0.0428571428571429,
gs = 0.0714285714285714, pnc = 0.0714285714285714, citi = 0.0857142857142857,
amex = 0.0857142857142857, spgl = 0.0857142857142857, jpm = 0.1,
brk = 0.1, ms = 0.114285714285714, wf = 0.114285714285714, bofa = 0.128571428571429
))

degree.unl <- unlist(degree.l)

Options: ReplyQuote


Sorry, only registered users may post in this forum.
This forum powered by Phorum.