Question: Using functions from the package ` dplyr ` , split the values in the column ` Sub Category ` into the columns ` Category `

Using functions from the package `dplyr`, split the values in the column `Sub Category` into the columns `Category` and `Sub Category` according to the following rules:
1. Split the values based on the first occurrence of `-`
2. When `-` does not occur do not split the value. In this case simply use the original value as the `Category` and set the `Sub Category` as NA
3. When there is more than one occurrence of `-`, do not perform any additional splits.
Store your answer as the object `q4`.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!