From rdpeng at gmail.com  Thu Jul 27 14:28:19 2006
From: rdpeng at gmail.com (Roger D. Peng)
Date: Thu, 27 Jul 2006 08:28:19 -0400
Subject: [Rd] how to start local scope?
In-Reply-To: <20060727121613.GA4594@pu100877.student.princeton.edu>
References: <20060727121613.GA4594@pu100877.student.princeton.edu>
Message-ID: <44C8B163.10501@gmail.com>

Try

f <- function() {
	local({
		b <- 1
	})
	b + 2
}


Tamas K Papp wrote:
> How can I start a local scope inside an R function?  Eg in
> 
>> b
> Error: object "b" not found
>> f <- function() {
> +   {
> +     b <- 1
> +   }
> +   b+2
> + }
>> f()
> [1] 3
> 
> I would like f() to report an error, not finding b.  I am thinking
> about something like let in Scheme/Lisp.
> 
> Thanks,
> 
> Tamas
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 

-- 
Roger D. Peng  |  http://www.biostat.jhsph.edu/~rpeng/



[Rd] how to start local scope?
Roger D. Peng