I'm trying to count the number of times that some pre-specified words appear in a character column, Post.
This is what my dataset looks like:

Now, I want to count all green/sustainable words in each of the posts and add this number as an extra column.
I have manually created a lexicon where all green words have Polarity == 1 and non-green words have Polarity == 0.

How can I do this?
str_count()fromstringrcan help with this (and with a lot more string-based tasks, see this R4DS chapter).Output:
Created on 2022-07-15 by the reprex package (v2.0.1)