[R] Substituting functions in package - Lattice

Saptarshi Guha sapsi at pobox.com
Wed Mar 7 00:24:27 CET 2007


Hi,
	Got it. This worked
	environment(print.trellis) <- getNamespace("lattice")
	where print.trellis is my modified print.trellis.
	
	Thanks.
	Regards
	Saptarshi

Saptarshi Guha | sapsi at pobox.com | http://www.stat.purdue.edu/~sguha

On Mar 6, 2007, at 5:29 PM, Greg Snow wrote:

> You need to set the environment on your version of print.trellis to
> match that of the original (at least that is what has worked for me  
> when
> trying to do modified functions from the trellis package).  Try
> something like:
>
>> environment(print.trellis) <- environment(lattice::print.trellis)
>
> Hope this helps,
>
> -- 
> Gregory (Greg) L. Snow Ph.D.
> Statistical Data Center
> Intermountain Healthcare
> greg.snow at intermountainmail.org
> (801) 408-8111
>
>
>
>> -----Original Message-----
>> From: r-help-bounces at stat.math.ethz.ch
>> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Saptarshi Guha
>> Sent: Tuesday, March 06, 2007 2:55 PM
>> To: R-Help
>> Subject: [R] Substituting functions in package - Lattice
>>
>> Hi,
>> 	I'm trying to learn how a package works but
>> substituting a parituclart function with my own (basically
>> the original one with some debug statements).
>> 	The package is lattice and the method is
>> "print.trellis" which is a
>> S3 method and is not visible.
>> 	To replace this, i sourced a file with the rewritten
>> print.trellis, and the old one was replaced.
>> 	However, i get this error when I attempt to print a
>> trellis object (e.g an xyplot)
>> 	
>> 	Error in assign("last.object", x, env = .LatticeEnv) :
>> 	object ".LatticeEnv" not found
>> 	
>> 	I notice that .LatticeEnv is defined in zzz.R (in the R
>> folder of the lattice source).
>>
>> 	My question, how does one do development on the lattice
>> package without having to recompile everything and install a package?
>>
>> 	I read something about emacs and development (i use
>> emacs) in the zzz.R file
>> 	"## .First.lib will be used if the NAMESPACE file is
>> missing.  This is ## useful during development, thanks to C-c
>> C-l in Emacs/ESS. It won't ## be used if a NAMESPACE file is
>> present.  Note: Due to registration ## of C functions done in
>> the NAMESPACE file, wireframe (and possibly ## cloud) won't
>> work in this scenario."
>>
>> 	But couldn't quite figure it out.
>> 	Thanks for any help provided.
>> 	Saptarshi
>>
>>
>> Saptarshi Guha | sapsi at pobox.com | http://www.stat.purdue.edu/~sguha
>>
>>
>> 	[[alternative HTML version deleted]]
>>
>> ______________________________________________
>> 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.
>>
>
> ______________________________________________
> 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.



More information about the R-help mailing list