8

it is probably bad style but can I modify options on package loading? E.g. my package should set the following options

options(java.parameters = "-Xmx8000m")
options(dplyr.width = Inf)
lattice.options(default.args = list(as.table = TRUE))
lattice.options(skip.boundary.labels = 0)
ckluss
  • 1,477
  • 4
  • 21
  • 33

1 Answers1

13

Yes, of course you can -- use the .onAttach() function for that. You then may want to make sure you document this, though, and maybe restore it when the package unloads.

Whether you should is not so clear. As an alternative (which may be more common) you can also set personal preferences in ~/.Rprofile or the site-wide Rprofile.site. I often do that for myself and colleagues for things like remote server settings.

Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725
  • 2
    Example use of `.onAttach()` to set package options in the [rpushbullet package by Dirk Eddelbuettel](https://github.com/eddelbuettel/rpushbullet/blob/master/R/init.R). – Paul Rougieux Aug 28 '17 at 10:13