0

I am running an analysis that produces a list of which elements in the input vector produced an error. Some of these are up to 50 elements. E.g.:

# Tags not found in the detection data

# A69-1602-19332, A69-1602-19328, A69-1602-54640, A69-1602-19333, A69-1602-19330, 
# A69-1602-24389, A69-1602-54698, A69-1602-54697, A69-1602-19360, A69-1602-24329, 
# A69-1602-19340, A69-1602-54648

Technically, the tags here are in the data, but refining the analysis by timeframe always has some come up that were not detected in that particular window. So far, I have been searching for each element, finding the row number, and dropping just that element with

bad_tags <- c(1, 2, 5, 6, 8, 11, 53, 82, 99, 102)
new_vector <- data_vector[-bad_tags]

The error output allows me to set up the following vector with relative ease, but I can't for the life of me figure out how to apply it to meet my needs. Is it possible?

bad_tags_names <- c("A69-1602-19332", "A69-1602-19328", ...)
new_vector <- data_vector ????

Relatively new at R but familiar with tidyr/dplyr and the like. I just can't figure this one out; really appreciate any input!

edits requested below

    bbmm.data <- dynBBMM(
  input = rsp.data,
  base.raster = base.raster,
  start.time = '2020-06-16 00:00:00',
  stop.time = '2020-08-31 23:59:59',
  UTM = 10,
  verbose = TRUE
)

rsp.data is produced by package RSP and is a large list of 6 elements produced in package actel. One of the elements is the list of all tags from the larger analysis done earlier.

When I run this code, I get the error output in the original question.

  • There may be a better way to solve your issue than to run the code, get an error, and then produce a vector based on the error. Can you give a small reproducible example of the list and what causes the error? – LMc Mar 23 '21 at 20:43
  • You talk about "data" and "rows", which suggests you're working with a data frame with multiple columns, but your example code is all vectors. Could you confirm which you're dealing with? It would also help if you would give sample input. You show a nice example of `bad_tag_names`, but no example of what `data_vector` looks like. – Gregor Thomas Mar 23 '21 at 20:47
  • That said, if you are dealing with vectors, there are many ways to do this. Two good ways would be `setdiff(data_vector, bad_tags_names)` or `data_vector[!data_vector %in% bad_tags_names]`. – Gregor Thomas Mar 23 '21 at 20:48
  • Unfortunately, I think a small reprex is not possible because the packages I'm using. The outputs of one all work in another and the particular code I'm calling pulls from three different lists under the hood. In this particular case I would have to repeat all of the prior analyses with subset data in order to catch it before the error. – Joe Bottoms Mar 23 '21 at 20:52
  • @JoeBottoms can you create something fake that has a similar structure and problem to be solved so we can get an idea? As mentioned above, it's difficult to tell what you're dealing with from the information you've given. – LMc Mar 23 '21 at 20:55
  • The data 'vector' is a large list (6 elements, 158.1 mb). In that list is a vector with all of the possible tag names. When I need to change the inputs of the code to a certain timeframe, then any of the tags from the total list that didn't fall in that timeframe throw an error. – Joe Bottoms Mar 23 '21 at 20:56
  • I've edited the post to include the example – Joe Bottoms Mar 23 '21 at 21:01
  • Gregor - that worked flawlessly for my needs. Cheers! – Joe Bottoms Mar 23 '21 at 21:15

0 Answers0