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 6591329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:24:36+00:00 2026-05-25T17:24:36+00:00

Supposed I am pulling the synonyms of help by the function of synonyms() from

  • 0

Supposed I am pulling the synonyms of “help” by the function of synonyms() from wordnet and get the followings:

Str = synonyms("help")    
Str
[1] "c(\"aid\", \"assist\", \"assistance\", \"help\")"     
[2] "c(\"aid\", \"assistance\", \"help\")"                 
[3] "c(\"assistant\", \"helper\", \"help\", \"supporter\")"
[4] "c(\"avail\", \"help\", \"service\")"  

Then I can get a one character string using

unique(unlist(lapply(parse(text=Str),eval)))

at the end that looks like this:

[1] "aid"        "assist"     "assistance" "help"       "assistant"  "helper"     "supporter" 
[8] "avail"      "service"

The above process was suggested by Gabor Grothendieck. His/Her solution is good, but I still couldn’t figure out that if I change the query term into “company”, “boy”, or someone else, an error message will be responsed.

One possible reason maybe due to the “sixth” synonym of “company” (please see below) is a single term and does not follow the format of “c(\”company\”)”.

synonyms("company")

[1] "c(\"caller\", \"company\")"                                    
[2] "c(\"company\", \"companionship\", \"fellowship\", \"society\")"
[3] "c(\"company\", \"troupe\")"                                    
[4] "c(\"party\", \"company\")"                                     
[5] "c(\"ship's company\", \"company\")"                            
[6] "company"

Could someone kindly help me to solve this problem.
Many thanks.

  • 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-05-25T17:24:37+00:00Added an answer on May 25, 2026 at 5:24 pm

    You can solve this by creating a little helper function that uses R’s try mechanism to catch errors. In this case, if the eval produces an error, then return the original string, else return the result of eval:

    Create a helper function:

    evalOrValue <- function(expr, ...){
      z <- try(eval(expr, ...), TRUE)
      if(inherits(z, "try-error")) as.character(expr) else unlist(z)
    }
    
    unique(unlist(sapply(parse(text=Str), evalOrValue)))
    

    Produces:

    [1] "caller"         "company"        "companionship" 
    [4] "fellowship"     "society"        "troupe"        
    [7] "party"          "ship's company"
    

    I reproduced your data and then used dput to reproduce it here:

    Str <- c("c(\"caller\", \"company\")", "c(\"company\", \"companionship\", \"fellowship\", \"society\")", 
    "c(\"company\", \"troupe\")", "c(\"party\", \"company\")", "c(\"ship's company\", \"company\")", 
    "company")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

From my server I'm pulling down a url that is supposed to simply be
I have a string I'm pulling from a Filemaker database that's supposed to read
Supposed I have the following string: string str = <tag>text</tag>; And I would like
I have a geocoding function that is pulling the address values entered into a
I'm pulling content from a DB that has been sanitized using mysql_real_escape_string. Accordingly the
I'm having an issue when pulling/listing an event feed from Google Calendar in python,
Suppose I have a task that is pulling elements from a java.util.concurrent.BlockingQueue and processing
Im pulling in xml data from the output of a php script. The way
I have a query that is supposed to pull records from several tables using
I am pulling back some data from the twitter query API, and parsing it

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.