I have function that takes the form
myfun<-function(Year, ID, Species, Abundance, resamps) {do something}
"resamps" means resampling and it takes a single number (e.g. 20)
I had no problem applying the function over a dataframe as it accepts data in the form:
<-myfun(mydata$Year, mydata$Bay, mydata$Species, mydata$Abundance, 20)
I need to apply this function over a list with the following structure
$ TX_ARAB:Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 308670 obs. of 4 variables:
..$ Year : chr [1:308670] "1982" "1982" "1982" "1982" ...
..$ Bay : chr [1:308670] "TX_ARAB" "TX_ARAB" "TX_ARAB" "TX_ARAB" ...
..$ Species : chr [1:308670] "Anchoa mitchilli" "Brevoortia patronus" "Dorosoma cepedianum" "Leiostomus xanthurus" ...
..$ Abundance: num [1:308670] 1 243 1 24 3 6 26 6 1 1 ...
$ TX_COCB:Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 344467 obs. of 4 variables:
..$ Year : chr [1:344467] "1982" "1982" "1982" "1982" ...
..$ Bay : chr [1:344467] "TX_COCB" "TX_COCB" "TX_COCB" "TX_COCB" ...
..$ Species : chr [1:344467] "Anchoa mitchilli" "Micropogonias undulatus" "Ariopsis felis" "Archosargus probatocephalus" ...
..$ Abundance: num [1:344467] 6 17 10 1 16 3 2 42 1 11 ...
It's no surprise that it didn't work when I did
d = lapply(mylist, myfun, resamps = 20)
I don't know how to get the function to accordingly use relevant object in the list given that I had to pass the data name with the objects when it was applied over a dataframe.