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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:10:43+00:00 2026-05-25T13:10:43+00:00

If I have this data set Browser Count Chrome/11 100 Chrome/11 89 Chrome/13 10

  • 0

If I have this data set

Browser          Count
Chrome/11         100
Chrome/11         89
Chrome/13         10
Safari/12         40
Safari/114        30      

And I want to get a more general form of the browser without the version number.

Browser          Clean_Browser       Count
Chrome/11         Chrome              100
Chrome/11         Chrome              89
Chrome/13         Chrome              10
Safari/12         Safari              40 
Safari/114        Safari              30

I know this is easy to do with python or excel, but is there a way to do it in R so I don’t have to pre-process the data?

  • 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-25T13:10:43+00:00Added an answer on May 25, 2026 at 1:10 pm

    That is pretty straightforward thanks to the regular expressions as well as string processing — both are vectorised so you do not need to loop. You could use

    • gsub() et al and replace ‘/…’ with blanks

    • even use strsplit with ‘/’ as the split character and retain the first

    • certainly other ways I can’t think of now, and experience suggests several will involve packages by Hadley 🙂 [kidding aside, look at the stringr package too]

    Here is approach one, done on a vector but a column in a data.frame is just the same:

    R> vec <- c( paste("Chrome", 11:13, sep="/"), paste("Safari", 101:102, sep="/"))
    R> vec
    [1] "Chrome/11"  "Chrome/12"  "Chrome/13"  "Safari/101" "Safari/102"
    R> newvec <- gsub("/.*$", "", vec, perl=TRUE)
    R> newvec
    [1] "Chrome" "Chrome" "Chrome" "Safari" "Safari"
    R> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have this set of data that we need to get the average of
I have a data set that looks like this: 000 100 200 300 010
I have a set of data that is structured like this: ItemA.GroupA ItemB.GroupA ItemC.GroupB
I have a set of data, with columns x and y. This set contains
I have classes like this public class someList { public string strOne {get; set;}
I have a DataSet consisting of XML data, I can easily output this to
I have this data from a xml file: <?xml version=1.0 encoding=utf-8 ?> <words> <id>...</id>
I have this class: public MyClass { public void initialize(Collection<String> data) { this.data =
SO I have the following set of code parsing delicious information. It prints data
SO I have the following set of code parsing delicious information. It prints data

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.