search for: sethook

Displaying 20 results from an estimated 40 matches for "sethook".

2008 Feb 29
1
setHook and lattice
Hi, I am trying to find a way to automate production of page numbers in plots produced using the lattice package. To do this, I started playing around with setHook which works fine with vanilla plot, but the hook 'plot.new' doesn't appear to be relevant to the lattice package. I was wondering if there is a alternative someone can suggest for use with the lattice package. Example code: library(lattice) graphics.off() myFunc <- function() {...
2005 Jun 10
1
Exiting R and package detachment?
Hi, is there away to assure that a package is detached when R quits? I know about .Last(), but that requires the user to setup that function. What I am looking for is a way for the package to do this itself, without asking the user to edit "their" .Last(). From ?setHook I know that: "...when an R is finished, packages are not detached and namespaces are not unloaded, so the corresponding hooks will not be run." I am going to use this to load settings from file when a package loads and automatically save (by optionally prompting the user) them back...
2006 Jan 05
0
.Rprofile files (was R newbie configuration)
Thanks a lot. setHook is Currently not in my knowledge set But it's great to save these Thing so I can look them up When I feel more comfortable. Just to add to that Stata versus R discussion : I believe, anyone who uses any other package than R, is probably missing out in the long run. It's truly unbelievabl...
2006 Feb 15
1
S3 generics without NS and cleanEx()
...orsten R> invisible(options(echo = TRUE)) R> ### * <HEADER> R> ### R> attach(NULL, name = "CheckExEnv") R> assign(".CheckExEnv", as.environment(2), pos = length(search())) # base R> ## add some hooks to label plot pages for base and grid graphics R> setHook("plot.new", ".newplot.hook") R> setHook("persp", ".newplot.hook") R> setHook("grid.newpage", ".gridplot.hook") R> R> assign("cleanEx", + function(env = .GlobalEnv) { + rm(list = ls(envir = env, all.names =...
2004 Oct 20
2
par() defaults in Rprofile
Dear List, I've tried to set default par() in .Rprofile by putting the following in the .First function: setHook(packageEvent("graphics", "onLoad"), function(...) {graphics::par(cex.axis=1.5, cex.lab=2, las=1)} ) My goal was to set par() defaults without opening a device everytime at startup. However, the next plot I create doesn't show these defaults. Any suggesti...
2013 Jul 15
2
suppress startup messages from default packages
Hi all, several packages print messages during loading. How do I avoid to see them when the packages are in the defaultPackages? Here is an example. With this in ~/.Rprofile ,----[ ~/.Rprofile ] | old <- getOption("defaultPackages") | options(defaultPackages = c(old, "filehash")) | rm(old) `---- I get as last line when starting R: ,---- | filehash: Simple key-value
2004 May 21
2
.First() in R 1.9.0
Dear R experts, I just upgraded R from 1.8.1 to 1.9.0 version. My .First() function in ~/.Rprofile contains x11() and par() functions. .First <- function() { x11(display = "", 8.0, 5.0) par(las = 1, ...) ## ... } And, R claims now, on startup: [hello messages skiped ...] Error in .First() : couldn't find function "x11" > I commented
2008 May 23
0
A problem about the Japanese font of OSX
Many Japanese were troubled with the setting of the font. I added the following to .Rprofile first. setHook(packageEvent("grDevices", "onLoad"), function(...){ grDevices::quartzFonts(sans=grDevices::quartzFont( c("Hiragino Kaku Gothic Pro W3", "Hiragino Kaku Gothic Pro W6&quo...
2004 Jul 21
2
add more data to a data file, problem with .Rprofile
Hi, Is there a way to incorporate an R object x to a file already containing R objects? It seems that 'save' is not capable to do this. If I save x to a file containing previously saved data, then I will lose this data. I use the funcion hsv in .Rprofile but it is recognized. Couriously, if I source .Rprofile when R is already running I do not get any error message. Thank you.
2004 Oct 28
2
Errors during make check
On a SUN 280R running Solaris 9... The configure and make steps completed without errors. But when I try to perform the make check step, I get the following: $ make check FORCE=FORCE `Makedeps' is up to date. running code in 'base-Ex.R' ...*** Error code 1 make: Fatal error: Command failed for target `base-Ex.Rout' Current working directory /usr/local/R-2.0.0/tests/Examples ***
2006 Jan 04
1
R newbie configuration
I think I did enough reading on my Own about startup ( part of the morning And most of this afternoon ) to not feel uncomfortable asking for confirmation of my understanding of this startup stuff. Obviously, the startup process is more complicated Than below but, for my R newbie purposes, It seems like I can think of the startup process as follows : Suppose my home directory =
2004 Apr 28
2
Rtemp directories accumulating over time
Hola! There is a nuisance that the number of directories with name starting Rtmp (and always empty) in my temp directory is increasing over time. I put the following in my .Rprofile: tmp0001 <- tempdir() setHook( packageEvent("base","onUnload"), function(...) unlink( tmp0001, recursive=TRUE) ) which solves part of the problem, but not all. So there are also other tmpdirs made by R. Why, where, and why are they not removed at exit (when their content are removed)? Kjetil Halv...
2011 Aug 08
1
Overwriting imported function in another package
..., pos="package:grid") #this seems ok: get('grid.newpage', as.environment("package:grid")); get('grid.newpage', as.environment("package:lattice")); #but this is still the old one get('grid.newpage', environment(histogram)); #test if it worked: setHook("before.plot.new", function() {message("Yay! A new plot.");}); qplot(rnorm(100)); #it worked for ggplot2 histogram(rnorm(100)); #didn't work for lattice
2008 Apr 29
1
Annoying bug in package cairoDevice
...iro_png draws the box even when par(bty="n"). I just tested this on Debian with version 2.6 of cairoDevice. I've also observed this behavior on Windows and it's not a new problem. The only workaround I've found is to call > Cairo_png() > par(col="white") > setHook("plot.new", function() par(col="black")) > plot(...) As far as I'm concerned, this is a serious bug, it's a real problem when creating figures for publication. I'd like confirmation that this is, in fact, a bug as I haven't seen much documentation for standar...
2010 Apr 21
2
problem of R CMD check
Hi all, Today, i just installed the newest R version 2.10.1 and other necessary tools for building R package under windows,e.g. Rtools, perl. All are the newest version. After the correct configuration under windows, i use it to re-check my old package. I found the following prolem when checking EXAMPLE, which did not exist before this re-installation. ######## * checking examples ... ERROR
2005 Aug 11
1
Registering S3 class from external package
...perform the registration once the other package has done so. But my namespace is locked by the time this occurs. Can someone either tell me how to do this, suggest a better alternative, or point me to another package that does something similar? Current attempt is something like the following: setHook(packageEvent("somepkg", "attach"), function(...) { cat("* Register", sQuote("oldstyle"), "as S3 class", "\n") setOldClass(c("oldstyle", "data.frame"),...
2004 Aug 10
0
Check failed after compilation (PR#7159)
...lt;- (oma4 <- pp$oma[4]) > 0; mar4 <- pp$mar[4] + mtext(paste("help(", ..nameEx, ")"), side = 4, + line = if(outer)max(1, oma4 - 1) else min(1, mar4 - 1), + outer = outer, adj = 1, cex = .8, col = "orchid", las=3) + } + } > setHook("plot.new", .newplot.hook) > setHook("persp", .newplot.hook) > rm(.newplot.hook) > ## add some hooks to label plot pages for grid graphics > .gridplot.hook <- function() + { + pushViewport(viewport(width=unit(1, "npc") - unit(1, "lines"), +...
2008 Feb 25
4
New version of X11, png and jpeg
...) with a slow connection between the machine running R and the X server. The additional software might not work correctly. The new versions are not currently the default, but can be made so by setting X11.options(type="Cairo"), e.g. as a load hook for package grDevices. I am using setHook(packageEvent("grDevices", "onLoad"), function(...) { grDevices::ps.options(horizontal=FALSE) if(getRversion() >= '2.7.0') grDevices::X11.options(type="Cairo") }) Please try these out and let us know how you get on. As a check,...
2004 Apr 13
1
par() in .Rprofile
Dear all I installed new version (from binaries) and I noticed that par(bg="white") which I have in my .Rprofile causes error message on startup But if I issued this command immediately after startup everything worked as expected. I did not see any note in changes file or elsewhere. Should I specify white background in .Rprofile differently? Or is there some other recommended way
2004 Apr 25
2
.Rprofile error: ps.options
After upgrading to R 1.9.0, I started getting the following error on startup: Error: couldn't find function "ps.options" My .Rprofile file contains this line: ps.options(paper="letter",horizontal=F) If I type "source ~/.Rprofile" after R starts, it works just fine. Did something related to startup change in R 1.9.0? -akop