'create new column based on existing pattern R
I have this
tableRules <- as.data.table(data.frame(object_name = c("instr_asset_row","functional_cat","ref_sector_second")))
listDimPoss <- c("instr_asset","ref_sector","functional_cat")
I want to create a new column in tableRules: tableRules$DIMENSION that will check in tablerules$object_name if the value includes the patterns listed in listdimPoss. If yes, then I want the value of tableRules$Rimension to be the pattern listed in listDimPoss. so here I want as a results
tableRules$DIMENSION <- c("instr_asset","functional_cat","ref_sector")))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
