Hi Abhilash, >From ?example, under "arguments":
local: logical: if ‘TRUE’ evaluate locally, if ‘FALSE’ evaluate in the workspace. So all you need to do is: > x <- 0 > example(mean, local=TRUE) mean> x <- c(0:10, 50) mean> xm <- mean(x) mean> c(xm, mean(x, trim = 0.10)) [1] 8.75 5.50 mean> mean(USArrests, trim = 0.2) Murder Assault UrbanPop Rape 7.42 167.60 66.20 20.16 > x [1] 0 and nothing in your workspace is changed. Best, Ethan On Sun, Jun 5, 2011 at 11:13 AM, Abhilash Balakrishnan <balaab...@gmail.com> wrote: > Dear Sirs, > > I am exploring the R package and its documentation. I find there is the > function example which runs examples from documentation pages. What > confuses me is that running example interferes with the variables I have in > my workspace. > >> x <- 0 >> example(mean) >> x > Now x is a vector of some values coming from the example. > > Am I using example in the wrong way? In situation like above running > example apparently corrupts existing data, pollutes the workspace with > variables I didn't create myself, and also leaves allocated data that > consume memory. Is there a way to run example to avoid this? I tried the > following: > >> x <- 0 >> local(example(mean)) >> x > Still x is corrupted with example data. > > Thank you for support. > Abhilash B. > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@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. > ______________________________________________ R-help@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.