[R] How to findout the name of a dataframe
dwinsemius at comcast.net
Sun Feb 17 19:32:45 CET 2013
On Feb 17, 2013, at 5:51 AM, Frans Marcelissen wrote:
> Let'say we have a dataframe mydata with column v1. If mydata$v1 is passed
> to a function, is there way, then, to extract the name of the dataframe?
> What I now do is passing the name of the dataframe to the funcion, so
> passing two parameters. Maybe with mydata$v1 it is not possible, but with
> mydata['v1'] or mydata[,'v1'] it is?
It will depend on the specifics. The usual way is with deparse(substitute(arg))
> d <- data.frame(a="a")
> gn <- function(col) print(deparse(substitute(col)))
You do realize that mydata$v1 is identical (after evaluation, anyway) to mydata[,'v1'] , but not to mydata['v1'], don't you?
> Frans Marcelissen
> fransiepansiekevertje at gmail.com
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
Alameda, CA, USA
More information about the R-help