I have a data frame similar to this
dput(sample_data)
structure(list(listing_id = c(12899L, 12899L, 12899L, 12899L,
12899L, 12899L, 12899L, 12899L, 12899L, 12899L, 12899L, 12899L,
12899L, 12899L, 12899L, 12899L, 12899L, 12899L, 12899L, 12899L,
12899L, 12899L, 12899L, 12899L, 12899L, 12899L, 12899L, 12899L,
12899L, 12899L, 12899L, 12899L, 12899L, 12899L, 12899L, 12899L,
12899L, 12899L, 12899L, 12899L, 12899L, 12899L, 12899L, 12899L,
12899L, 12899L, 12899L, 12899L, 12899L, 12899L, 12899L, 12899L,
12899L, 12899L, 12899L, 12899L, 12899L, 12899L, 12899L, 12899L,
12899L, 12899L, 12899L, 12899L, 12899L, 12899L, 12899L, 12899L,
12899L, 12899L, 12899L, 12899L, 12899L, 12899L, 12899L, 12899L,
12899L, 12899L, 12899L, 12899L), id = c(24767, 29230, 29806,
32572, 32862, 40792, 43566, 43920, 46120, 48434, 52902, 57458,
61672, 68414, 71418, 74541, 75259, 77605, 78600, 79300, 80982,
82555, 83752, 98488, 99753, 102145, 105460, 107350, 111060, 118238,
122914, 130226, 150419, 176176, 179317, 183355, 188840, 200734,
213728, 216268, 219476, 224141, 230224, 242707, 256155, 271224,
274658, 299623, 305993, 326731, 348879, 358361, 365440, 405902,
416997, 421410, 431327, 439108, 450967, 462680, 475923, 497264,
504158, 512703, 569301, 592555, 611971, 621267, 634440, 636623,
666385, 721778, 735454, 744152, 777928, 786787, 811911, 821548,
833250, 848303), date = c("24/01/2010", "13/03/2010", "16/03/2010",
"31/03/2010", "02/04/2010", "08/05/2010", "17/05/2010", "18/05/2010",
"24/05/2010", "31/05/2010", "14/06/2010", "26/06/2010", "06/07/2010",
"24/07/2010", "31/07/2010", "06/08/2010", "07/08/2010", "12/08/2010",
"15/08/2010", "16/08/2010", "18/08/2010", "22/08/2010", "24/08/2010",
"16/09/2010", "18/09/2010", "21/09/2010", "26/09/2010", "28/09/2010",
"04/10/2010", "13/10/2010", "19/10/2010", "31/10/2010", "07/12/2010",
"30/01/2011", "07/02/2011", "16/02/2011", "26/02/2011", "16/03/2011",
"31/03/2011", "03/04/2011", "06/04/2011", "12/04/2011", "18/04/2011",
"27/04/2011", "09/05/2011", "19/05/2011", "22/05/2011", "06/06/2011",
"09/06/2011", "21/06/2011", "02/07/2011", "07/07/2011", "11/07/2011",
"30/07/2011", "03/08/2011", "05/08/2011", "09/08/2011", "12/08/2011",
"16/08/2011", "21/08/2011", "26/08/2011", "03/09/2011", "05/09/2011",
"08/09/2011", "26/09/2011", "03/10/2011", "09/10/2011", "11/10/2011",
"16/10/2011", "17/10/2011", "26/10/2011", "15/11/2011", "21/11/2011",
"26/11/2011", "11/12/2011", "15/12/2011", "29/12/2011", "01/01/2012",
"03/01/2012", "07/01/2012"), reviewer_id = c(69327L, 72846L,
84196L, 89114L, 100318L, 106706L, 122590L, 124878L, 115296L,
128686L, 101332L, 133253L, 61601L, 170065L, 89041L, 174803L,
189922L, 53967L, 97181L, 165949L, 169685L, 166756L, 24799L, 1972408L,
214136L, 212710L, 216604L, 49785L, 205468L, 207387L, 232310L,
202219L, 290589L, 339123L, 128686L, 112038L, 385948L, 409204L,
406780L, 382114L, 153837L, 117790L, 430323L, 501446L, 102379L,
574784L, 476509L, 493172L, 656282L, 614047L, 755566L, 555937L,
193404L, 12386L, 650075L, 794170L, 348567L, 820789L, 888114L,
817107L, 546440L, 791723L, 989632L, 588916L, 1013150L, 888114L,
1128969L, 450362L, 166365L, 894104L, 1206085L, 1296041L, 1390344L,
1215456L, 1421703L, 970946L, 26035L, 1540509L, 1502615L, 1486972L
), reviewer_name = c("Stuart", "John", "Lois", "Troy", "Cathy",
"Johanna", "Madelyn", "Adam", "Craig", "Leah", "Christopher",
"John & Lyn", "Nick", "Hope & Sebastien", "Ariel", "Marilyn",
"Kathy", "Erik", "Angela", "Erica", "Susan", "Darrell", "Mavis",
"Jaclyn", "Jen", "Frederick", "Linda", "Barrett", "Lynda", "Sarah",
"Maneesh", "Constance", "Chris", "Toby", "Leah", "Vincent", "Ellen",
"Fran", "Mark", "Ryan", "James", "Sally", "Annette", "Lynne",
"Angela", "Katie And Tommy", "Leigh", "Liz", "David", "Diana",
"Iñaki", "Mary", "Wendy", "Adrian", "Joan", "Kristine", "Jovana",
"Beth", "Deevy", "Craig", "Jennifer", "Barbara", "Biff", "Kelly",
"Amanda", "Deevy", "Pieter & Dietsje", "Johnny", "Sherri", "Suzette",
"Nancy", "Duncan", "Rebecca", "Pam", "Kaitlin", "Paul & Iho & Alexandrea & Anabella",
"Norma", "Kim", "Ana", "Daron"), comments = c("recommended very good value spacious airy upper floor alison david welcoming helpful",
"our ten days visiting portland enormously enhanced alison david they contributed welcoming warmth wonderful economical accomodations if lucky enough get back portland maine imagine staying anywhere else br jack lorel",
"we wonderful time staying area alberta arts the beds comfy upstairs spacious with walk 5 blocks found great food including thai one try chicken satay ali david amazing home filled great atmosphere lots laughs definitely place revisit",
"i stayed ali david s place i first moved portland the space comfortable private lots room ali david knowledgeable portland neighborhoods get around anyone coming portland will enjoy stay here",
"clean comfortable quiet rooms easygoing generous hosts great walking neighborhood close parks seemingly unlimited restaurant choices wish able stay longer",
"beautiful neighborhood convenient airport interstate considerate hosts comfortable spacious private rooms i asked better highly recommend anyone traveling portland",
"this space ideal 3 adults my wife sister i spent weekend portland stayed here we found space clean hosts friendly neighborhood quiet we never part portland happened come local street fair ended finding good vegetarian fare just blocks away enjoyed walking street we will definitely consider space option visiting portland",
"beautiful house cute neighborhood the hosts gracious helpful without over bearing two bedrooms small kitchen space coffee maker small bathroom shower provided enough space highly recommended anyone looking something personal hotel room better price too",
"wonderful gracious welcoming hosts when i asked david child barrier stairs quickly came solution they provide place way home hotel gave us insight portland help us move i recommend place highly very clean quiet neighborhood thanks ali david",
"i recommend place enough the rooms bright pretty even gray day hosts just terrific knowledgeable friendly generous when i found i d forgotten running shoes ali lent me hers i m indebted life especially since i indulging wonderful food prepared many marvelous restaurants found mere blocks away should prefer something simpler new seasons within easy walking distance plus two massage studios two yoga studios just close who ask more",
"allison david stellar hosts combining available attentiveness needs quiet leisurely atmosphere home space comfortable spotless alli s garden inspiring perfect holiday",
"had great time dave ali they friendly helpful nothing much trouble the room private comfortable bathroom sole use plenty eating places nearby try hamburgers new seasons highly recommended",
"fantastic spot comfy clean quiet prime location even got nice bike ride in a ideal place spend days portland",
"unfortunately able chat much ali david busy seem lovely br br the suite wonderful place stay hubbub really tourist y areas there great restaurants nearby though walking around area cinch make sure look bus routes if car get here house obvious frequent route although knew busses best easy br br ali david good resource great place stay",
"we asked much hosts ali david welcoming room clean bed soooo comfy our time portland definitely enhanced staying here couldn t recommend more",
"this perfect space charming convenient neighborhood hosts helpful intrusive a great find",
"very clean quiet friendly hosts we enjoyed two night stay much recommend highly great places eat alberta area",
"great hosts classic quiet portland home the converted attic almost apartment great access northeast portland scene",
"ali dave warm gracious hosts we arrived late flight willing wait us the place lovely clean conveniently located we definitely recommend staying here",
"i wonderful introduction portland staying clean comfy spacious appartment ali dave s charming home i overnighted moved quickly i get spend much time ali dave however charming helpful throughout stay the room ideally located get airport short taxi ride the location great artsy laid back spot cool places eat coffee generally absorb atmosphere genuine portland neighborhood",
"my family great time portland kastners helpful giving suggestions restaurants places hike visit",
"david ali s husband made us feel welcome time met us door left unfortunately able stay one night comfortable place stay time everything clean comfortable just amenities needed br we highly recommend lovely apartment friends br br annette spratt br leavenworth ks",
"we couple third person home absolutely perfect us comfortable beds kitchen facilities microwave bar sink small fridge plates etc the hosts superb warm gracious friendly a 10 minute drive city center a definite return place us",
"much enjoyed ali dave wish time chat them eager provide valuable information things see including kennedy school enjoyed much little apartment upstairs perfect two friends travel together need separate rooms need frequently overlooked typical b bs friend seattle appreciated sharing little kitchenette separate bedrooms br br i m moving portland alabama hope touch ali dave settling in great hosts also interesting people recommend highly anyone traveling portland br br luba",
"huge space friendly owners just needed very nicely located close alberta street bars food portland hippies br br will definitely stay poor",
"clean place nice people good coffee", "what fabulous place stay it s beautiful house rental space great way beyond expectations you can walk new seasons coffee shops alberta killingsworth around lovely neighborhood nearby parks it s lovely sit front porch just happy portland br br david ali wonderful hosts they friendly informative welcoming my first night took time sit porch talk making feel especially welcome br br i imagine staying anywhere else portland next visit",
"david ali great hosts upstairs clean comfortable the neighborhood nice great restaurants within walking distance a great place stay",
"my daughters enjoyed stay much david ali wonderful hosts helpful the neighborhood nice ali david gave girls discount coupon one local sushi restaurants enjoyed much br we definitely recommend br br br",
"ali david wonderful hosts they warm generous spirits made us feel welcome br br the house located beautiful neighborhood front back gardens lush green it s gorgeous spacious house hardwood floors the upstairs stayed great its completely new clean everything need a big comfy bed nice view garden small kitchen ish area fridge sink microwave everything perfectly new clean good order br br eric i cat people although two new teenage cats stay downstairs plenty time play pet them really liked it real comfort us stay there home away home describes perfectly br br if plans visit portland place stay br br we hope stay next trip portland already recommended family coming visit future br br rating 10 plus stars",
"i pulled house ali david porch gave warm welcome it felt like staying friends rather strangers a really comfortable apartment within walking distance alberta arts district the apartment clean comfortable quiet i will definitely stay again",
"we great time visiting family portland staying ali david s home very clean quiet sleeping pleasant environment david ali friendly low key perfect hosts close alberta new seasons good stuff definitely recommend place anyone",
"great hosts great place great neighborhood ali david bent backwards make sure stay incredible the place cozy inviting everything just right the neighborhood lacks nothing i ll stay sure",
"ali dave s house gorgeous upstairs apartment awesome it super clean spacious well decorated stocked little kitchenette plates utensils clean towels shower they super friendly hosts cute cats even gave us fresh coffee grounds the area really great too reason may stay now planning buy place near",
"oh always really lovely time ali david s pretty festive home as usual fun exchanges books cats recipes thank you ali david",
"ali david great hosts we felt comfortable living situation will repeat next time chance the home great neighborhood within walking distance needs our regret getting know hosts better seem like great people",
"ali dave great hosts br br they kind thoughtful welcoming warm and oh helpful information go do br br because visit working retreat insider information helped make great use time br br i got choice rooms picked smaller one just right amount space one person cozy comfortable br and within walking distance alberta street i needed great shops restaurants fantastic",
"a perfect 10 i wonderful stay ali david from first ali responsive via email easy arrange stay when i arrived david greeted got settled the rooms wonderful david made sure i warm enough the rooms classic portland simple uncluttered big windows looking green trees ali supplied tea small fridge milk etc the big bed comfy perfect snuggling blankets rain drumming softly roof in evenings i enjoyed hanging them sitting fire playing kitties walking concordia alehouse fries drink",
"ali david great hosts friendly easy talk to gave us real welcome home portland feel the suite comfortable we enjoyed mini kitchen convenience stocked coffee too the spacious warm bedroom with extra blankets provided needed privacy much appreciated the neighborhood quiet beautiful close everything we strongly recommend staying portland ali david hope able return someday",
"david ali wonderful house just blocks eclectic lively alberta street northwest pdx the upstairs space available comfortable roomy perfect stays length br br both david ali offered great advice must dos pdx first timer generous offering extra bicycle weekend making initial two wheeled bridgetown experience authentic br br next time i m back i ll here",
"ali david wonderful hosts provided really great place stay very accommodating flexible house beautiful parking easy everything exceeded expectations hesitate stay again",
"ali david s suite spacious lovely clean private there small kitchen area coffee maker coffe tea provided ali david great hosts friendly helpful i able park car front house every night just short walk interesting alberta arts district",
"this first stay booked via airbnb fantastic david allie responsive first booking email i departed they available helpful i also felt i good bit privacy the space lovely coffee maker coffee microwave fridge the location also great near airport neighborhood lots going on available easy parking i enjoyed nearby new seasons market extracto coffee the wifi included fast i able watch shows hulu check e mail etc i slept well quite bed comfy lots blankets pillows provided",
"we much enjoyed stay the kastner s suite cold perfect the space really large multiple rooms plenty closet space the bed truly comfortable linens nicely done plenty hot water there small kitchenette area provided coffee they live beautiful quiet street able park right front house every night even though private entrance space still felt private in fact times coming going either ali david home since come front door chances visit added enjoyment staying there we hope stay whenever portland",
"jenny i attended acupuncture class portand delightful stay br with david alison their lovely home quick walk great restaurants br a grocery store yoga studio etc david alison excellent hosts br providing beautiful quiet place stay generously inviting us join br in neighborhood events they great suggestions enjoy area br including lending us 2 bicycles explore it we wonderful time br highly recommend staying them br",
"ali david accommodating space clean due flight cancellations travel disasters time ali david cut short one night kind enough offer us refund stayed late following evening welcome us home david even made list vegetarian restaurants open late i grab food finally got there the space clean warm hosts beyond kind welcoming our brief memories portland definitely shaped ali david s hospitality upon returning portland love stay will recommend friends future",
"ali dave great unfortunately i much loved spend time alberta arts district the neighborhood cute felt safe the bus one block away i loved eats coffee cup saucer cafe the space ample clean sleep several it nice cup tea getting ready day thank dave ali accommodation random hours",
"what delightful surprise lovely home lovely gardens welcoming hosts we two couples plenty room us",
"this first experience airbnb great start the home tastefully decorated quiet ali david gracious helpful the neighborhood beautiful great restaurants interesting art galleries walking distance",
"we wonderful four day stay all advertised meticulously clean wonderfully comfortable space ali david thoughtful relaxed helpful hosts plus great location lovely home cute kitties recommended without qualification",
"lovely house suite entire second floor clean spacious easy go downtown portland using public bus just 2 blocks away alberta arts district st something recommendable specially last thursday month ali david great hosts knowledgeable city",
"we wonderful experience beautiful house lovely people the rooms spotless comfortable welcome received david ali warm friendly br this area portland full nice cafes restaurants within walking distance within easy access city centre",
"dave waiting us front yard late nightly arrived perfect host moment on ali town much stay enjoyed meeting well the rooms nice coffee welcome space absolutely spotless we enjoyed immensely happy stay again thanks making wonderful experience",
"beautiful area helpful hosts they flexible time wise ex helped late checkout i ve never seen beautiful sidewalk 31st venue alberta br br the space nicely appointed refinished attic including shower plenty hot water sink fridge 2 rooms beds there air conditioning floor fan keeping windows open fine us watch low ceiling tall like me br br internet provided fast wife completely unable connect if depend 100 reliable quick internet bring plan wifi time around nearby cafe s opening hours br br for liesure traveler great spot 2 buses nearby couple inexpensive restaurants within 15 minute walk br br if use hidden airbnb maps note zipcode phone number hidden airbnb phone number hidden airbnb can really confuse things via bus can get downtown within phone number hidden airbnb minutes depending timeliness route make sure note odd bus fare 2 05 via cab 15 downtown 20 airport br br anyway i hope expanse tips prove useful you alberta arts great place consider looking relaxing leisure trip portland",
"the alberta arts suite just perfect i traveled 18 year old daughter 2 bedrooms worked great the suite just pictured clean modern everything need stay the house located beautiful neighborhood portland ali david wonderful hosts when come portland again will stay again",
"david ali superb hosts their home front gardens lovely upstairs suite guests just weary travelers needed the space gave us room spread relax perfect the alberta neighborhood fun us explore fun shopping resale shops great restaurants galleries within walking distance i hesitate recommend spot friends thanks great stay david ali",
"we wonderful time ali david s home the space beautiful extremely clean quiet hosts considerate accommodating ie made iron ironing board available us helped faulty internet connection laptop offered advice city transportation overall stay ali david again recommend travelers",
"we wonderful stay really wonderful people went beyond ensuring comfortable stay good location great experience",
"my friend i enjoyed ali david s place immensely it perfect needed great snapshot great pdx neighborhood i ll come back sure",
"the stay wonderful room clean nice my girlfriend i felt welcome i definitely stay again",
"we wonderful stay ali dave generous helpful from kind welcome directions recharging ipod whole experience made stay portland great",
"i want live accommodation well thought supplied great location intelligent gentle attentive hosts a real winner",
"if going portland couple nights longer fantastic place stay great neighborhood easy walk bike things might want ali david wonderful hosts",
"ali david great hosts their space cute clean they accommodating made sure everything needed they also good suggesting delicious neighborhood restaurants if ever portland area will definitely checking see space available",
"the alberta arts studio great place weekend visit the suite lots space clean uncluttered the neighbourhood fantastic lots great restaurants shops within 10min walk it 30min leisurely bike ride downtown lovely neighbourhoods we found david ali friendly helpful tips suggestions things do the studio lots portland magazines maps us read on it also great use bikes although kitties may suffer allergies they come suite day so friends definitely feeling itchy eyed br having stayed great place definitely added fantastic portland weekend getaway",
"once again great stay we love ali david s house neighborhood this second stay time three us their place just great three two thanks",
"we great time alberta arts a nive location portland great city the room clean spacious the hosts helpfull nice people general we will come back area sure",
"lovely place stay great hosts", "my husband adult daughter i enjoyed stay ali david they greeted us street evening made us feel welcome comfortable they quick help forgotten shampoo providing ironing board iron needed them we used rooms just like photos clean clutter free they live beautiful portland neighborhood fun restaurants shops i recommend contact need place two nights portland br",
"my daughter i enjoyed stay ali dave they nicer my flight arrived late friday dave waiting outside umbrella pulled 11 pm they great communicators along way the rooms comfortable quiet peaceful amenities internet microwave fridge sink advertised they informative gracious hosts providing right measure privacy help finding looking for my daughter mentioned enjoyed spoken word next morning found note date time venue poetry slam went enjoyed immensely web searching find otherwise known this i doubt hotel concierge taken time find us i highly recommend staying dave ali return get portland again",
"spacious quiet comfortable additional benefit small kitchenette very accessible public transportation close airport great choice anyone wants ne portland",
"alison david went beyond expectations hosts incredibly kind warm people they made us feel welcome home immediately questions concerns even just chat br br the private space upstairs house quiet cozy comfortable they attended amenities even finer details br br we amazing stay here slept like babies night stay anywhere else come back portland br br thanks ali david",
"this first experience airbnb will certainly back ali david wonderful hosts two bedrooms upstairs space husband 16 year old daughter i stayed comfortable quiet amenities possibly wanted everything went smoothly we also liked within walking distance restaurants cafes shops within easy driving distance downtown portland lewis clark college omsi",
"our stay comfortable quiet i agree others said cleaner nicer pictures might indicate seemed brand new spotless ali david accommodating hosts david met us helped carry bags upstairs br my warning might six two ceilings attic type husband connected ceiling one occasion i however loved it felt cozy roomy since heighth foot shorter his i definitely recommend it",
"very comfortable quiet the entire upstairs floor classic portland bungalow ali husband made feel right home super easy make reservation even though i contacted last minute place stay i live portland town visitor location perfect access portland s fun unique shopping dining areas",
"ali david wonderful hosts we needed quiet secluded place days exactly got we whole second floor private bathroom it also quiet clean the neighborhood wonderful everything needed within walking distance grocery store restaurants yoga we recommend place others",
"the accommodations clean quiet david ali helpful cheerful hosts we enjoyed visiting look forward return visit soon we love location well since close wonderful new season s market alberta street restaurants street parking easy all pleasant stay comfortable clean surroundings excellent hosts",
"we delightful stay ali david just new years their upstairs guest suite met needs perfectly clean comfortable quiet charming part portland we definitely recommend place anyone",
"ali david friendly hosts made sure needed we good stay them room again",
"ali s place perfect just advertised i plenty privacy lots space i definitely stay again"
)), row.names = c(NA, 80L), class = "data.frame")
I have done the preprocessing part and I want ti filter the data frame on two parts containing some strings "pets," "pet," "cat," "cats," "dog," and "dogs" I have tried the following
Filter_pets<-sample_data %>%
filter(grepl("dog|cat|pet|pets|dogs|cats ",comments))
and
Filter_no_pets<-USA_data %>%
filter(!grepl("pet|^cat|dog|pets|dogs|cats",comments))
It is not prodicing the desired results. For example, if some word is there called "Cater" it still filters it to assign it to the first data frame. Also it is not capturing everu term inclduing "pets" Can anyone help?
\bis a word boundary in regex. So"\\bcat\\b"(double-escaped for R) will matchcatbut notcater. You can also use?as a "if it's there" quantifier, so"\\bcats?\\b"will match "cat" and "cats" but not "cater". I would strongly recommend debugging your regex on ~10 test cases using regex101 before trying it on your whole data.