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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:56:40+00:00 2026-06-06T01:56:40+00:00

I have a question about removing non-alphanumeric characters from a list in R. I

  • 0

I have a question about removing non-alphanumeric characters from a list in R. I have a list will all sorts of odd characters, blanks, etc. and would like to remove them. I’m generally able to remove what I want using the tm package in r. I fiddled around with it, but got nowhere so thought going back to the list may be the place to start.

The list:

 list("\n    \n", "\n\n  ", "\n        ", "               ", "\n    ", 
 "\n            \n      ", "\n        ", "Home", "\n", "Expertise", 
 "Question & Research Design", "\n", "Survey Development & Validation", 
 "\n", "Data Processing", "\n", "Statistical Analysis", "\n", 
 "Publications & Grants", "\n", "Evaluation", "\n", "\n", 
 "Consulting Areas", "Business", "\n", "Education", "K-12", 
 "\n", "Â ", " Â Â  Â  Â", " | ")

The expected output

[1] ""                               ""                         ""
[4] ""                               ""                         ""
[7] ""                               "Home"                     ""
[10] "Expertise"                     "Question Research Design" ""
[13] "Survey Development Validation" ""                         "Data Processing"
[16] ""                              "Statistical Analysis"     ""
[19] "Publications Grants"           ""                         "Evaluation"
[22] ""                              ""                         "Consulting Areas"
[25] "Business"                      ""                         "Education"
[28] "K12"                           ""                         ""
[31] ""                              ""
  • 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-06T01:56:41+00:00Added an answer on June 6, 2026 at 1:56 am

    Strongly recommend you simply use

    gsub("[^a-zA-Z0-9]","",x)
    

    where x is the name of the list.

    You probably included the foreign characters at the end of the list because you want these obliterating too – well, the above command achieves this. To explain briefly, the square brackets in the command define a collection of symbols, and the ^ symbol means “not”, so everything that is not in the specified set of 62 characters (lower case a to z, upper case A to Z, and digits 0 to 9) will be replaced by the empty string “” (i.e. destroyed).

    And here’s the output…

     [1] ""                             ""                        ""
     [4] ""                             ""                        ""
     [7] ""                             "Home"                    ""
    [10] "Expertise"                    "QuestionResearchDesign"  ""
    [13] "SurveyDevelopmentValidation"  ""                        "DataProcessing"
    [16] ""                             "StatisticalAnalysis"     ""
    [19] "PublicationsGrants"           ""                        "Evaluation"
    [22] ""                             ""                        "ConsultingAreas"
    [25] "Business"                     ""                        "Education"
    [28] "K12"                          ""                        ""
    [31] ""                             ""
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have question about removing element from QList. myclass.h: class node2D : public QObject
I have a question about wiring web server controls. From many of the examples
I have a rather specific question about how to exclude items of one list
I have a basic question about manually removing event listeners in actionscript 3. If
I have a question about thread safety. From what I have been told, SimpleDateFormat
This question is about removing sequences from an array, not duplicates in the strict
A question was asked recently about removing SourceSafe integration from Visual Studio 6 .
I have question about normalization. Suppose I have an applications dealing with songs. First
I have question about interpreting strings as packed binary data in C++. In python,
i have question about YAJLiOS parser... I have next json data : {{ body

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.