0

I have a dataset where one variable is text from tweets (text). I want to detect all tweets matching at least one element in my vector (Ukr_words_MIX). Here is what I tried to do, using::rtweet, string_detect and apply

input

con_ukr_words_NOR <- df_A_NOR %>%
 mutate(text = tolower(text),
 lapply(x = Ukr_words_MIX, function(x){
 str_detect(string = text, pattern = x)})

output

> con_ukr_words_NOR <- df_A_NOR%>%
+   mutate(text = tolower(text),
+   lapply(x = Ukr_words_MIX, function(x){
+   str_detect(string = text, pattern = x)})
+ View(df_A)
Error: unexpected symbol in:
"  str_detect(string = text, pattern = x)})

Any ideas about what I am doing wrong?

Thank you!

RagnaN
  • 1
  • 1
  • 1
    It would be helpful if you could provide a reproducible example refer https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Nad Pat Mar 14 '22 at 14:02
  • In the simple sense, you have an extra closing paren. Perhaps I'm missing something, but I don't think this code snippet overall will do what you intend. – Bill O'Brien Mar 14 '22 at 14:10
  • Can you post a sample of your data using `dput(df_A_NOR)`? – jdobres Mar 14 '22 at 14:15

0 Answers0