Hi guys,

I'm quite new to R but quite enthousiastic. I'm trying to rewrite a bit of
code in order to make it faster, so instead of nesting for loops I'm trying
some apply functions. Since it's a combination of lists of matrices and
other matrices, I would like to use lapply() on the list and still be able
to use the list index to index in the matrices.

So, in "code format"-
x <- list()
for (i in 1:10){
  x[[i]] <- c(1:i)
}

lapply(x,length)

is there a possible way to say "lapply(x, function(x) length(x)/index(x) )"
and return 1's. I would be looking for the index. I know that row() and
col() work in the matrix case. I would find it interesting to use it with
arrays as well.

Many thanks in advance!

Regards,
Mark


--
View this message in context: 
http://r.789695.n4.nabble.com/row-col-function-but-for-a-list-probably-very-easy-question-cannot-seem-to-find-it-though-tp4504216p4504216.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to