【发布时间】:2019-03-28 12:55:27
【问题描述】:
我有其中一列的数据
Activity Description
---------------------------------------------
Handling & PNR Movement Charges-FCL
Value Added Charges
Container Tracking Charges-FCL
Contrainer Ground Rent Charges-FCL
Documentation Charges FCL
Insurance Charges-FCL
Seal Charges
Fuel Charges-FCL
Container Movement and Increase Charges-FCL
Weighment Charges-FCL
Container Movement and Increase Charges-FCL
我需要搜索包含“FCL”的字符串并替换没有 FCL 的单词。 前任。保险费-FCL 到保险费,即我不需要字符串 FCL。
我试过下面的代码,
for (line in file_read$`Activity Description`){
if (line == "*FCL"){
new_column <- c(new_column,"*")
它不工作。
我的代码是否正确,或者我需要使用另一个代码脚本进行更改?
谁能帮我解决这个问题?
【问题讨论】:
-
sub("FCL", "", file_read$Activity Description) -
你能展示一个更大的数据集吗?
FCL是否总是出现在字符串的末尾,前面有一个破折号? -
谢谢它的工作。
-
真的有用吗?它不会在你的名字中留下破折号吗?
-
@TimBiegeleisen,它用破折号打印,但我怎样才能删除破折号,但字符串有破折号而另一个字符串没有
标签: r