David Go
David Go

Reputation: 840

how do I get the variable name of a list

I'm trying to read the name of an object of type list. i.e.

myList <- list("foo","foo1")

The way I normally read object names is:

deparse(substitute(myList))

however in case of this list it returns:

"list(\"foo\", \"foo1\")"

The result I want is "myList". Can anyone help?

Upvotes: 1

Views: 59

Answers (1)

David Go
David Go

Reputation: 840

The way how I'd read a function actually returns the desired result unlikely I mentioned first.

 as.character(substitute(myList))

Upvotes: 3

Related Questions