I have a data set called one_plot, the head of which can be seen below. I am trying to add a column to label rows based on their subCategory_id
using the dplyr package.
For example subCategory_id %in% c(1:4)
to be labeled as "Premium"
, subCategory_id %in% c(4:12)
to be labeled "Base"
and subCategory_id %in% c(12:20)
to be labeled "Other"
.
Data looks like this:
product_id product_origin product_price subCategory_id GBP
1 Australia 0.36154597 1 371.31
2 USA 0.14425684 1 148.15
3 USA 0.09020571 1 92.64
5 USA 0.35793051 1 367.59
6 USA 0.19523482 1 200.51
I tried using the command
one_plot$cat_type <- filter(one_plot, subCategory_id %in% c(1:4) = "Premium")