Мы можем использовать str_match()
или gsub()
(с немного другим синтаксисом).
library(stringr)
data = c("0.5", "-0.4*","1.8*", "2.5**", "0.8","-0.5")
#1. Matched all starting with - and ending without a star
str_match(data,"^-[0-9\\.]+[^\\*]$")
#2. Meches all not starting with - but ending with a star
str_match(data,"^[^-][0-9\\.]+\\*$")
Вы можете сохранить как CSV-файл и прочитать его в R.