我想使用stringr
和rebus
删除数据框中的部分字符串。具体来说,我想用空格和数字删除它开始的部分直到最后。
以下是我的数据框:
df<-data.frame(ID = 1:8, Medication = c("FOLIC ACID 5MG TABLET", "RIBAVIRIN 200MG TAB", "ACARBOSE 50MG TABLET",
"AmLODIPine 5MG TABLET", "MAGNESIUM TRISILICATE MIXTURE 200ML",
"RESONIUM 15G/60ML SUSPENSION", "CALCIUM & VIT D TABLET", NA))
我想要的数据框是:
df_new<-data.frame(ID = 1:8, Medication = c("FOLIC ACID", "RIBAVIRIN", "ACARBOSE",
"AmLODIPine", "MAGNESIUM TRISILICATE MIXTURE",
"RESONIUM", "CALCIUM & VIT D TABLET", NA))
我尝试了以下代码,但它只能帮助消除药物强度(例如5MG)而不是测量单位(例如TABLET):
df %>% mutate(Medication = str_replace(Medication, pattern = SPC %R%
one_or_more(DGT) %R%
one_or_more(WRD) %R%
or(one_or_more(SPC), one_or_more(WRD)),
replace = ""))
我该如何解决这个问题?
答案 0 :(得分:1)
System.NullReferenceException: Object reference not set to an instance of an object.
02-01 14:03:09.660 I/MonoDroid(24139): at AppDesign.CheckInternetCon.RunInBackground (Java.Lang.Void[] params)