Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 204771

find the string present and update the frequency

$
0
0

I have 2 dataframes, I am trying to find if the words from df dataframe is present in dataframe sentence's texts then I need to mutate source values as columns and print frequency for each source value. Please help me to achieve this!

df <- data.frame(words = c("this","when","from","car","good"), source = c("name1", "name1","name2", "name2","name3"))

sentence <- data.frame(Textno = c(1,2,3),texts = c("when this job comes", "the car is good", "from here"))

Expected Output

Textno  texts                name1 name2 name3
  1     when this job comes    2     0     0
  2     the car is good        0     1     0
  3     from here              0     0     1


Viewing all articles
Browse latest Browse all 204771

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>