I have two data frames, One has the product name & the other has the categories..now I need to match the category to the product name & assign respective categories to the names if the string is matched.

So 1st data frame containing the product name (Product\_Name.csv) is:

```
           **Product.Name**
       Black Printed Blouse
Silver Embellished Crop Top
   Maroon Solid Strappy Top

```

The other data frame contaning the categories (Category.csv)is:

```
**Category**
     Strappy
      Blouse
        Crop 

```

Final Output Should be:

```
       Black Printed Blouse       Blouse
Silver Embellished Crop Top         Crop
   Maroon Solid Strappy Top      Strappy

```

Now, I am using grepl which gives true or false

```
product <- read.csv("Product_Name.csv", header = T, sep = ",")
category <- read.csv("Category.csv", header = T, sep = ",")

for (i in 1:nrow(product)){

product[i, 2] <- grepl(Category$Category[1], product$Product.Name[i], ignore.case = TRUE)
product[i, 3] <- grepl(Category$Category[2], product$Product.Name[i], ignore.case = TRUE)
product[i, 4] <- grepl(Category$Category[3], product$Product.Name[i], ignore.case = TRUE)

}

```