Finally understood instructions and goals. Wrote fn based on Peng's cachemean.R. Receiving error