Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Find a certain word in a string using R

I’m trying to use the billboard tibble in R to find all the songs titles that contain the word "Love" in them using string basics but I’m struggling.

The end result should look like this:

 [1]"I'm Outta Love"          "My First Love"
 [3] "My Love Goes On And ..." "He Loves U Not"
 [5] "Love Is Blind"           "I Will Love Again"      
 [7] "Feels Like Love"         "Let's Make Love" 
 [9] "My Love Is Your Love"    "It Must Be Love"        
 [11] "He Can't Love U"         "I Just Wanna Love U ..."
 [13] "U Don't Love Me"         "Don't Say You Love M..."
 [15] "Love's The Only Hous..." "Because You Love Me"    
 [17] "Love Sets You Free"      "I Knew I Loved You"     
 [19] "I Think I'm In Love ..." "Live, Laugh, Love"      
 [21] "The Chain Of Love"

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

data("billboard")

billboard$track[grepl("Love", billboard$track)]

#  [1] "I'm Outta Love"          "My First Love"           "My Love Goes On And ..." "He Loves U Not"          "Love Is Blind"          
#  [6] "I Will Love Again"       "Feels Like Love"         "Let's Make Love"         "My Love Is Your Love"    "It Must Be Love"        
# [11] "He Can't Love U"         "I Just Wanna Love U ..." "U Don't Love Me"         "Don't Say You Love M..." "Love's The Only Hous..."
# [16] "Because You Love Me"     "Love Sets You Free"      "I Knew I Loved You"      "I Think I'm In Love ..." "Live, Laugh, Love"      
# [21] "The Chain Of Love"  
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading