I have 2 lists of matrices A and B:
n<-10
generate<-function (n){
matrix(runif(10*10),ncol = 10)
}
A<-lapply(1:n, generate)
B<-lapply(1:n, generate)
I am trying to use lapply to run it through a function with two inputs. Where my function is a function I have createdABC()
:
ABC(x,y)
I now try to run the lists A for x and B for y by using lapply:
l<-lapply(A,B, ABC(x,y))
This does not work as it recognises B as a function instead of a list that should be associated with y. Do I need to use sapply
or mapply
and if so how?
Any help would be appreciated, thanks.