How to determine if a string "ends with" another string in R? -
i want filter out rows of table contain '*' in string value of column. checking column.
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", : not find function "substrright" the 4th value of zz should true this.
in python there endswith function strings [ string_s.endswith('*') ] there similar in r ?
also, problem because of '*' character means character ? grepl not working.
> grepl("*^",'dddd*') [1] true > grepl("*^",'dddd') [1] true
this simple plenty don't need regular expressions.
> string_name = c("aaaaa", "bbbbb", "ccccc", "dddd*", "eee*eee") > substring(string_name, nchar(string_name)) == "*" [1] false false false true false r string ends-with
No comments:
Post a Comment