[R] Treating variables as symbols

Henrique Dallazuanna wwwhsd at gmail.com
Thu Oct 1 15:53:47 CEST 2009


Try this:

y <- function(a)
	substitute(a * x, list(a = a))

On Thu, Oct 1, 2009 at 10:46 AM, ZeMajik <zemajik at gmail.com> wrote:
> Hey,
> I'm trying to find how to perform operations with a variable treated as a
> symbol.
> For, an extremely simple, example I want to integrate a*x with respect to x
> and I want to find the indefinite integral of this, (a*x^2/2), or the
> definite integral with some interval for x.
>
> Another example of such a use would be to create a function
> y<-function(x) {a*x}
> and by typig y(2) I would get the result 2*a
>
> Is there a way to treat variables as merely "symbols"?
> Any help much appreciated
>
> -M
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org 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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O




More information about the R-help mailing list