Posts

Showing posts with the label stringr

Using str_split and removing duplicate values from the same record in R

Using str_split and removing duplicate values from the same record in R I have a data frame of book genres. It began as two columns, one for the title and one for a character string containing multiple genres, similar to this: titles <- c("Harry Potter 1", "To Kill A Mockingbird", "The Hunger Games 1") genres <- c("Fantasy, Young Adult, Fantasy, Magic", "Classics, Fiction, Historical, Historical Fiction, Academic", "Young Adult, Fiction, Science Fiction, Dystopia, Science Fiction") books <- tibble( title = titles, genre = genres) books # A tibble: 3 x 2 title genre <chr> <chr> 1 Harry Potter 1 Fantasy, Young Adult, Fantasy, Magic 2 To Kill A Mockingbird Classics, Fiction, Historical, Historical Fiction, Academic 3 ...

Extracting quantity elements from name in R

Extracting quantity elements from name in R I have a Dataset in which one of the column name is "Name" which contains name of the product including the quantity (size) of the product as shown below. Alkabeer Paratha Plain 400 GM Almarai Fresh Laban Baladi 2 L Americana Breaded Chicken Burger 1 KG Dac Glass Cleaner 4 L Duru Body Soap Fruity 125 GM - 4 Pcs Lux Liquid Handwash Soft Touch 250 ML Lux Liquid Handwash Magical Beauty 250 ML Lusine Sliced Bread Multi Grain 600 GM Orinex Containers Bowl 25 Oz - 4 Pcs Betty Crocker Frosting Vanilla 400 GM Freshly Microwave Popcorn 3.5 Oz Gandour Potato Chips 145 Gm Galaxy Chocolate Milk 40 GM Nahool Jumbo Roll Strawberry 75 GM - 6 Pcs Nestle Sweetened Condensed Milk 397 GM Puck Cheese Triangle Value Pack 120 GM - 5 Pcs Betty Crocker Super Moist Cake Mix Choco Fudge 500 GM Some of the products are packed in a crate, for example "Duru Body Soap Fruity 125 GM - 4 Pcs" I would like to extract both the quantity and the size of...