Re: [R] Use mapply or lapply to a nested list

2020-12-22 Thread Chao Liu
Jim and Ben, Thank you for your help. I will play around the commands and function you suggested. Best, Chao On Tue, Dec 22, 2020 at 4:07 AM Jim Lemon wrote: > Hi Chao, > I think what you are looking for is the "rapply" function in the base > package. Not sure that it can do exactly what you

Re: [R] Use mapply or lapply to a nested list

2020-12-22 Thread Jim Lemon
Hi Chao, I think what you are looking for is the "rapply" function in the base package. Not sure that it can do exactly what you request but worth a look. Jim On Tue, Dec 22, 2020 at 6:36 AM Chao Liu wrote: > > I want to apply a sample function to a nested list (I will call this list > `bb`) and

Re: [R] Use mapply or lapply to a nested list

2020-12-21 Thread Ben Tupper
You might be able to get mapply to work, but because your lists differ in lengths you will get some recycling which may lead to mayhem for you. Below I have tried to simplify and clarify by naming the elements of your lists, but I don't get 20 results. I get 4 elements (one for each k). Each kth

[R] Use mapply or lapply to a nested list

2020-12-21 Thread Chao Liu
I want to apply a sample function to a nested list (I will call this list `bb`) and I also have a list of numbers (I will call this list `k`) to be supplied in the sample function. I would like each of the numbers in k to iterate through all the values of each list in bb. How to do this using `mapp