Flemish piece of code required

I know that perhaps this place is not the best for this type of requirement but maybe some of you are Belgian.
I need to find all records in my Belgian data where respondents replied "as above", "stated before", "left a comment already" and "na", "no comments", nothing to say".

I already have this pieces of code which should be updated:

blank_statements <- regex("no\\scomment?|nee|neen|^\\s*n.?a.?\\s*$", ignore_case = TRUE)

As_above = if_else(str_detect(comment, regex("zoals\\shierboven|eerder\\sgenoemd|Zoals\\svermeld", ignore_case = TRUE)), 1, 0)

but I know the list should be longer and it should include phrases in other main languages used in Belgium.

Can anyone help?

I would make a vector of the responses and then use %in% to detect them. You can use str_lower, str_tim, str_replace etc to avoid it being case sensitive, remove extra spaces, etc.

blank_statements <- c("as above", "stated before", "left a comment already", "na", "no comments", "nothing to say")

as_above <- comment %in% blank_statements

Thank you but:

  1. I have thie error after using your code:
Error in match(x, table, nomatch = 0L) : 
  'match' requires vector arguments
  1. You cannot include this excellent solution for multiple versions of "N/A" suggested by andresrcs:
blank_statements <- regex("^\\s*n.?a.?\\s*$", ignore_case = TRUE)

The regex string is cute but mine is much easier to follow.

So what format is your data in? Maybe you can post the output of dput(yourdata)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.