[R] Apply a loop containing a function on a list

jim holtman jholtman at gmail.com
Thu Mar 15 03:55:10 CET 2012

Without a subset of data, it is hard to come up with a solution.  Now
here is a way of determining what names are in common and then maybe
doing something:

B.names <- names(B.list)
A.names <- names(A.list)
common <- intersect(B.names, A.names)
for (i in common){
    B.list[[i]] <- function(A.list[[i]])

On Wed, Mar 14, 2012 at 3:51 AM, ali_protocol
<mohammadianalimohammadian at gmail.com> wrote:
> Hi all,
> I want to do this:
>        B.list$aa= (a loop containing My.fun acting on the reults of second
> function on a A.list$aa))
> or, overally
>        B.list$aa = function (A.list$aa)
> B.list and A.list has many sublists aa, ab and.... Is there a way I can
> apply the function and loop on all sublists of A.list and get B.list?
> Thanks in advance.
> --
> View this message in context: http://r.789695.n4.nabble.com/Apply-a-loop-containing-a-function-on-a-list-tp4471188p4471188.html
> Sent from the R help mailing list archive at Nabble.com.
> ______________________________________________
> R-help at 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.

Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

More information about the R-help mailing list