In general you can have rownames with characters like that in names and rownames, you just need to quote them when using them. I think the problem here is the subset
function, it allows some unusual ways to specify the subset which makes some things easier, but others harder. It is trying to figure out what you mean by the rownames (rather than just take them as literal strings) and the parentheses are probably confusing that process.
Try something like:
data[ grepl( paste0("v*[0-9]_",ws_names, collapse="|" ), rownames(data)), ]
You may also be able to simplify this using %in%
if you can construct the list of names.
Also see fortune(69)
, the ==TRUE is redundant and slightly less useful than adding 0 or multiplying by 1.