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

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -