Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8708419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:08:02+00:00 2026-06-13T04:08:02+00:00

I’m using R and I have a data.frame with nearly 2,000 entries that looks

  • 0

I’m using R and I have a data.frame with nearly 2,000 entries that looks as follows:

> head(PVs,15)
     LogFreq   Word PhonCV  FreqDev
1593     140    was    CVC 5.480774
482      139    had    CVC 5.438114
1681     138    zou   CVVC 5.395454
1662     137    zei    CVV 5.352794
1619     136   werd   CVCC 5.310134
1592     135  waren CVV-CV 5.267474
620      134    kon    CVC 5.224814
646      133   kwam   CCVC 5.182154
483      132 hadden CVC-CV 5.139494
436      131   ging    CVC 5.096834
734      130  moest  CVVCC 5.054174
1171     129  stond  CCVCC 5.011514
1654     128    zag    CVC 4.968854
1620     127 werden CVC-CV 4.926194
1683     126 zouden CVV-CV 4.883534

What I want to do is to create a new data.frame that is equal to PVs, except that all entries having as a member of the “Word” column a string of character that does NOT end in either “te” or “de” removed. i.e. All words not ending in either “de” or “te” should be removed from the data.frame.

I know how to slectively remove entries from data.frames using logical operators, but those work when you’re setting numeric criteria. I think to do this I need to use regular expressions, but sadly R is the only programming language I “know”, so I’m far from knowing what type of code to use here.

I appreciate your help.
Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T04:08:03+00:00Added an answer on June 13, 2026 at 4:08 am

    Method 1

    You can use grepl with an appropraite regular expression. Consider the following:

    x <- c("blank","wade","waste","rubbish","dedekind","bated")
    grepl("^.+(de|te)$",x)
    [1] FALSE  TRUE  TRUE FALSE FALSE FALSE
    

    The regular expression says begin (^) with anything any number of times (.+) and then find either de or te ((de|te)) then end ($).

    So for your data.frame try,

    subset(PVs,grepl("^.+(de|te)$",Word))
    

    Method 2

    To avoid the regexp method you can use a substr method instead.

    # substr the last two characters and test
    substr(x,nchar(x)-1,nchar(x)) %in% c("de","te")
    [1] FALSE  TRUE  TRUE FALSE FALSE FALSE
    

    So try:

    subset(PVs,substr(Word,nchar(Word)-1,nchar(Word)) %in% c("de","te"))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an autohotkey script which looks up a word in a bilingual dictionary
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I want to construct a data frame in an Rcpp function, but when I
I have thousands of HTML files to process using Groovy/Java and I need to
I have a small JavaScript validation script that validates inputs based on Regex. I
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.