loops - Subset vector based on table of logical values R -


I am trying to reduce a vector based on several inputs. File.list file names will be a vector that I want to subscribe, and species will be the species names that I want to search within the files.

  file.list & lt; - c ("blah_cod", "blah_had", "blah_ggu", "blah_cod") species & lt; - c ("cod", "was") a & lt; ([,,,,,,,,,,,,,,,,,,,,,,, 1]] file.list [a [, 2]]   

with code I am currently able to achieve what I want, but I should be able to automate it, the number of columns will depend on the number of inputs of the species by the user. I tried this like this:

  (i (1: ncol (a))) {b & lt; -file.list [a [, i]]}   

I along these lines Have tried too many combinations, but either I only know Or any idea to get a piece of information errors.?

grep in fact, rather than logical values ​​can be used for return mail: # [[]] [# 1] "blah_cod" "blah_cod" # # [[/>

  lapply (species , Grep, file.list, ignore.case = TRUE, value = TRUE) # [2]] # [1] "Blahahid"    

Comments

Popular posts from this blog

python - how we can use ajax() in views.py in django? -

matlab - Using loops to get multiple values into a cell -

python - Sequence Pattern recognition with Pybrain -