This must be a stupid question, but is there any "extension" of get?
For example:
x <- 10
get("x") # gives me 10
get("x^2") # gives me an error
Alberto Monteiro
Alberto Monteiro wrote:> This must be a stupid question, but is there any "extension" of get? > > For example: > x <- 10 > get("x") # gives me 10 > get("x^2") # gives me an errorThere is no object called "x^2" in the environments within your search path. If you want to calculate x^2, then type x^2 or get("x")^2 Uwe Ligges> Alberto Monteiro > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
it's unclear what you want ...
but
get("x")^2
does not give an error
hth, Ingmar
On 28 Feb 2007, at 15:35, Alberto Monteiro wrote:
> This must be a stupid question, but is there any "extension" of
get?
>
> For example:
> x <- 10
> get("x") # gives me 10
> get("x^2") # gives me an error
>
> Alberto Monteiro
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.
Alberto Monteiro wrote:> This must be a stupid question, but is there any "extension" of get? > > For example: > x <- 10 > get("x") # gives me 10 > get("x^2") # gives me an error'get' really only gets R objects - you want to evaluate an expression - like this: > x=2 > eval(parse(text="x^2")) [1] 4 Barry