I have two lists of dataframes. List x
and list my_list
. Each having four dataframes and their names are same for the two lists, i.e., bray-curtis, Chao1, FB
, and Shannon
.
The dataframes within the two lists have same element names, but they contain different information. This is because list x
has been generated after some operations on list my_list
.
Now I want to write a function and run that on list x
with `lapply. the command I want to write as a function is
forest(x$Chao1, slab = paste(my_list$Chao1$StudyID))
Here, the first Chao1
is coming from list x
while the second Chao1
is coming from the list my_list
. It works for a single dataframe but I am unable to write the codes with lapply
so that it runs across all the dataframes of the lists.
The desired outputs are four plots from four dataframes of list x
.
Can anyone please help me?
Update: @gringer's approach works, but it saves all the plots in a single list. When I tried to save the images with following command it just saved the last image:
tiff(filename = "~/Desktop/image.tiff", width = 30, height = 30, units = "cm", res = 1200)
Is there a way to save all them individually?
Thanks
my_list
andx
are the same, why do you need the names frommy_list
then? Also note you can edit your question and add all these details. Try for example, showing bits of the data.frames in the two lists, or something that would make us understand why you need two lists, not one. $\endgroup$