I have a stack of rasters (one per species) and then I have a data frame 
with lat/long columns along with a species name.

|fls=  list.files(pattern="median")
s<-  stack(fls)
df<-c("x","y","species name")|

I want to be able to just select one raster at a time to use with an 
extract function. I want the selection to be based on the partial match 
based on the species name column. I want to do this because the raster 
names might not match perfectly the names in the species list, there 
might be a lower/upper case mismatch or the raster layer name might be 
longer, for example "species_name_median", or there might also be "_" 
instead of a blank.

|for(i:length(df.species name))
{
   result<-extract(s[[partial  match to"species name[i]"  ]],df.xy)
}|

I hope this makes sense that I just want to use one raster at a time for 
the extraction. I am able to easily select a single raster using s[[i]] 
but there is no guarantee that every species in the list has its 
equivalent raster.


        [[alternative HTML version deleted]]

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

Reply via email to