[R] extract parts of a list before symbol
Evan Cooch
ev@n@cooch @end|ng |rom gm@||@com
Thu May 25 19:29:52 CEST 2023
Suppose I have the following list:
test <- list(a=3,b=5,c=11)
I'm trying to figure out how to extract the characters to the left of
the equal sign (i.e., I want to extract a list of the variable names, a,
b and c.
I've tried the permutations I know of involving sub - things like
sub("\\=.*", "", test), but no matter what I try, sub keeps returning
(3, 5, 11). In other words, even though I'm trying to extract the
'stuff' before the = sign, I seem to be successful only at grabbing the
stuff after the equal sign.
Pointers to the obvious fix? Thanks...
More information about the R-help
mailing list