I want to create a series of new objects for storing an analyses in, in a function. I want the function to have two arguments, one argument is a bunch of character strings and one is a numeric vector. Im fairly inexperienced with R so please if you could explain simply that would be much appreciated, with as much detail too, i see that a lot of people recommend the combination of paste and assign in situations similar to this, but i cant get it to work properly, and i also see a lot of recommendations for using lapply, but i cant get my head around how lapply is working, so if anyone has the skills to walk me through it in laymans terms it would be a massive help and much appreciated.
For example,
plant_species<-c("speciesA", "speciesB", "speciesC")
years<-(2005:2007)
which i would like to create the following objects from: speciesA2005, speciesA2006, speciesA2007, speciesB2006, speciesB2007, speciesB2008, speciesC2006, speciesC2007,speciesC2008.
But ideally I would like plant species and year to part of a function such as
myfunction<-function(year,species) {
}
which i could then give to someone else, so all they have to do is type
myfunction(2005:2007, "speciesA", "speciesB", "speciesC")
but it would be great if they could enter as many species as they like and the function recognised how many species they have entered and years and returned the appropriate number of objects
Many thanks