考慮我有一個df
:如果文本字符串包含那麼就有R中返回的東西
Product Category
Bill Payment for Torrent Power Limited
Recharge of Videocon d2h DTH
Bill Payment of Airtel Mobile
Recharge of Idea Mobile
現在,如果一個字符串包含「繳費」和「手機」兩個,然後我要標記其爲「類Postpaid「,如果一個字符串包含」Recharge「和」Mobile「,我想將其標記爲」Prepaid「。
我是R的初學者,所以最簡單的方法將不勝感激。
結果應該是
Product Category
Bill Payment for Torrent Power Limited NA
Recharge of Videocon d2h DTH NA
Bill Payment of Airtel Mobile Postpaid
Recharge of Idea Mobile Prepaid
DF $類別[grepl(」 Bill \\ sPayment「)&grepl(」Mobile「)] < - 」Postpaid「 –