auto set options in own package
Asked Answered
L

1

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)
Lachrymatory answered 23/5, 2015 at 10:40 Comment(0)
G
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.

Greenback answered 23/5, 2015 at 12:15 Comment(1)
Example use of .onAttach() to set package options in the rpushbullet package by Dirk Eddelbuettel.Mantra

© 2022 - 2024 — McMap. All rights reserved.