我想过滤掉在列的字符串值中包含'*'的表的行.只检查该列.
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"
Run Code Online (Sandbox Code Playgroud)
由此,zz的第4个值应该为TRUE.
在python中有字符串的endswith函数[string_s.endswith('*')]是否有类似于R的东西?
此外,它是否有问题,因为'*'作为一个字符,因为它意味着任何字符?grepl也没有用.
> grepl("*^",'dddd*')
[1] TRUE
> grepl("*^",'dddd')
[1] TRUE
Run Code Online (Sandbox Code Playgroud)