Skip to content
Prev 96099 / 398500 Next

Generate object names from variables

On Fri, 2006-07-14 at 16:57 +0200, Georg Otto wrote:
Presuming that your vectors fit a naming pattern of "vector.x":

# Use grep() to get the vector names from ls()
[1] "vector.a" "vector.b" "vector.c"

# Use sapply to create the list
$vector.a
[1] "a" "b"

$vector.b
[1] "c" "d"

$vector.c
[1] "e" "f"


HTH,

Marc Schwartz