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

2012-03-14 Thread ali_protocol
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@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.


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

2012-03-14 Thread Milan Bouchet-Valat
Le mercredi 14 mars 2012 à 00:51 -0700, ali_protocol a écrit :
 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?
Please provide a small example, you can easily create two lists to
illustrate your point. It's hard to help without that, it would require
us mocking up an example for you, and we might get it wrong.


Cheers

__
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.


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

2012-03-14 Thread jim holtman
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
mohammadianalimohammad...@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@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.

__
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.