I've seen the function lapply
used in R to extract elements from matrices that exist in a list of matrices.
E.g. I have a list of 3 (2x2) matrices, and I want to extract element [1,2] from each of those 3 matrices.
The code: list1 = lapply(mylist, '[', 1,2)
works just fine. It returns a list with those 3 elements.
I am trying to research what this is exactly doing. Google hasn't helped and using ?'['
in the R help isn't too explanatory. I don't see how '['
is a function in R, so the code is not intuitive.