列の文字列値に「*」を含むテーブルの行を除外したいと考えています。その列だけをチェックします。
string_name = c("aaaaa", "bbbbb", "ccccc", "dddd*", "eee*eee")
zz <- sapply(tx$variant_full_name, function(x) {substrRight(x, -1) =="*"})
Error in FUN(c("Agno I30N", "VP2 E17Q", "VP2 I204*", "VP3 I85F", "VP1 K73R", :
could not find function "substrRight"
これで zz の 4 番目の値が TRUE になるはずです。
Python には、文字列の endwith 関数があります [ string_s.endswith('*') ] R に似たようなものはありますか?
また、「*」は任意の文字を意味するため、文字として問題がありますか? grepも機能しません。
> grepl("*^",'dddd*')
[1] TRUE
> grepl("*^",'dddd')
[1] TRUE