I am receiving this error
Error in stri_detect_regex(string, pattern, opts_regex = opts(pattern)) : Incorrectly nested parentheses in regexp pattern. (U_REGEX_MISMATCHED_PAREN)
when I run the code
# find occurrences of initial dataframe
named_RN$search <- map_int(named_RN$V1, function(x){sum(str_detect(final_RN$named_RN, pattern = x))})
in which named_RN$V1
looks like
aldosterone
renin
potassium
calcitrol
and final_RN$named_RN
looks like
aldosterone, creatinine
human, warfarin
aspirin, renin, calcitrol
magnesium, calcitrol
and my code aims to create a new variable within named_RN
that shows the raw counts of each phrase, so that named_RN
looks like
V1 search
aldosterone 1
renin 0
potassium 0
calcitrol 2
Please advise. Thanks.
Since you are using fixed strings, not regular expressions, you need to tell the regex engine to use the patterns as plain, literal text. You can use it like this:
See "Fixed matches":
You might also consider
coll(x)
in case you want to use human-language collation rules while performing a case insensitive search.