[education/rkward] rkward/rbackend/rpackages/rkward: began cleaning the R code to get less warnings from R CMD check:

m.eik michalke null at kde.org
Mon Sep 11 21:23:41 BST 2023


Git commit ec7c7593f1997c0f6967b36cee10793b247ffd0f by m.eik michalke.
Committed on 11/09/2023 at 21:39.
Pushed by meikm into branch 'master'.

began cleaning the R code to get less warnings from R CMD check:

- fixed missing imports of many functions from grDevices, graphis and utils
- added googleVis, htmlwidgets, lattice, and R2HTML as suggested packages
- added calls to requireNamespace(), sometimes instead of require(), to only use functions from suggested packages if available
- commented out .rk.makeActiveBinding.default() and makeActiveBinding() (no longer used)
- updated rk.select.list() to use choices instead of list as the first argument (as used in select.list() since R 2.11)
- removed redundant uses of rkward:::
- fixed some links to other packages
- added some dummy objects so R CMD check doesn't complain about unknown variables
- in .rk.make.device.wrapper(), replaced grDevices::devicename with the more robust getFromNamespace(devicename, ns="grDevices")

M  +1    -0    rkward/rbackend/rpackages/rkward/DESCRIPTION
M  +25   -1    rkward/rbackend/rpackages/rkward/NAMESPACE
M  +18   -16   rkward/rbackend/rpackages/rkward/R/base_overrides.R
M  +8    -5    rkward/rbackend/rpackages/rkward/R/internal.R
M  +1    -0    rkward/rbackend/rpackages/rkward/R/internal_debugger.R
M  +28   -20   rkward/rbackend/rpackages/rkward/R/internal_graphics.R
M  +3    -0    rkward/rbackend/rpackages/rkward/R/internal_help.R
M  +24   -7    rkward/rbackend/rpackages/rkward/R/public_graphics.R
M  +7    -10   rkward/rbackend/rpackages/rkward/R/rk.KDE_GUI-functions.R
M  +1    -1    rkward/rbackend/rpackages/rkward/R/rk.plugin-functions.R
M  +36   -35   rkward/rbackend/rpackages/rkward/R/rk.print-functions.R
M  +1    -0    rkward/rbackend/rpackages/rkward/R/rk.sessionInfo.R
M  +5    -4    rkward/rbackend/rpackages/rkward/R/rk.utility-functions.R
M  +4    -3    rkward/rbackend/rpackages/rkward/R/rk.workspace-functions.R
M  +1    -3    rkward/rbackend/rpackages/rkward/man/rk.graph.on.Rd
M  +1    -1    rkward/rbackend/rpackages/rkward/man/rk.load.pluginmaps.Rd
M  +2    -3    rkward/rbackend/rpackages/rkward/man/rk.old.packages.Rd
M  +35   -35   rkward/rbackend/rpackages/rkward/man/rk.results.Rd
M  +2    -5    rkward/rbackend/rpackages/rkward/man/rk.show.messages.Rd
M  +2    -3    rkward/rbackend/rpackages/rkward/man/rk.workplace.Rd

https://invent.kde.org/education/rkward/-/commit/ec7c7593f1997c0f6967b36cee10793b247ffd0f

diff --git a/rkward/rbackend/rpackages/rkward/DESCRIPTION b/rkward/rbackend/rpackages/rkward/DESCRIPTION
index af9477eca..4c1522377 100755
--- a/rkward/rbackend/rpackages/rkward/DESCRIPTION
+++ b/rkward/rbackend/rpackages/rkward/DESCRIPTION
@@ -8,6 +8,7 @@ Description: This package contains functions which are useful in
 Author: Thomas Friedrichsmeier, RKWard Team
 Maintainer: RKWard-devel mailing list <rkward-devel at kde.org>
 Depends: R (>= 2.9.0),methods
+Suggests: googleVis,htmlwidgets,lattice,R2HTML
 URL: https://rkward.kde.org
 BugReports: https://rkward.kde.org/Bugs.html
 License: GPL (>= 2)
diff --git a/rkward/rbackend/rpackages/rkward/NAMESPACE b/rkward/rbackend/rpackages/rkward/NAMESPACE
index 3bcc1a433..ac5bfb021 100644
--- a/rkward/rbackend/rpackages/rkward/NAMESPACE
+++ b/rkward/rbackend/rpackages/rkward/NAMESPACE
@@ -39,7 +39,6 @@ export(.rk.with.window.hints)
 export(RK)
 export(Sys.setlocale)
 export(X11)
-export(makeActiveBinding)
 export(q)
 export(quartz)
 export(quit)
@@ -127,3 +126,28 @@ export(windows)
 export(x11)
 exportClasses(RK.Output)
 import(methods)
+importFrom(grDevices,dev.copy)
+importFrom(grDevices,dev.cur)
+importFrom(grDevices,dev.list)
+importFrom(grDevices,dev.new)
+importFrom(grDevices,dev.off)
+importFrom(grDevices,dev.set)
+importFrom(grDevices,jpeg)
+importFrom(grDevices,png)
+importFrom(grDevices,postscript)
+importFrom(graphics,par)
+importFrom(utils,URLdecode)
+importFrom(utils,URLencode)
+importFrom(utils,available.packages)
+importFrom(utils,capture.output)
+importFrom(utils,compareVersion)
+importFrom(utils,contrib.url)
+importFrom(utils,getCRANmirrors)
+importFrom(utils,getFromNamespace)
+importFrom(utils,help)
+importFrom(utils,help.search)
+importFrom(utils,installed.packages)
+importFrom(utils,menu)
+importFrom(utils,new.packages)
+importFrom(utils,old.packages)
+importFrom(utils,sessionInfo)
diff --git a/rkward/rbackend/rpackages/rkward/R/base_overrides.R b/rkward/rbackend/rpackages/rkward/R/base_overrides.R
index 6d7f425de..790330629 100644
--- a/rkward/rbackend/rpackages/rkward/R/base_overrides.R
+++ b/rkward/rbackend/rpackages/rkward/R/base_overrides.R
@@ -2,21 +2,23 @@
 # SPDX-FileCopyrightText: by Thomas Friedrichsmeier <thomas.friedrichsmeier at kdemail.net>
 # SPDX-FileContributor: The RKWard Team <rkward-devel at kde.org>
 # SPDX-License-Identifier: GPL-2.0-or-later
-# override makeActiveBinding: If active bindings are created in globalenv (), watch them properly
-# Ideally this would not be needed, but there seems to be no user-accessible way to copy unevaluated active bindings.
-.rk.makeActiveBinding.default <- base::makeActiveBinding
-#' @export
-"makeActiveBinding" <- function (sym, fun, env, ...) {
-	if (identical (env, globalenv ())) {
-		f <- .rk.make.watch.f (sym)
-		.rk.makeActiveBinding.default ("x", fun, environment(f), ...)
-		ret <- .rk.makeActiveBinding.default (sym, f, globalenv ())
-		.rk.watched.symbols[[sym]] <- TRUE
-		invisible(ret)
-	} else {
-		.rk.makeActiveBinding.default (sym, fun, env, ...)
-	}
-}
+
+### this is currently unused and therefore commented out
+## override makeActiveBinding: If active bindings are created in globalenv (), watch them properly
+## Ideally this would not be needed, but there seems to be no user-accessible way to copy unevaluated active bindings.
+#.rk.makeActiveBinding.default <- base::makeActiveBinding
+## @export
+#"makeActiveBinding" <- function (sym, fun, env, ...) {
+#	if (identical (env, globalenv ())) {
+#		f <- .rk.make.watch.f (sym)
+#		.rk.makeActiveBinding.default ("x", fun, environment(f), ...)
+#		ret <- .rk.makeActiveBinding.default (sym, f, globalenv ())
+#		.rk.watched.symbols[[sym]] <- TRUE
+#		invisible(ret)
+#	} else {
+#		.rk.makeActiveBinding.default (sym, fun, env, ...)
+#	}
+#}
 
 
 #' @export
@@ -44,7 +46,7 @@
 	if (isTRUE(.rk.inside.rkward.session())){
 		.rk.do.plain.call ("quit")
 	} else {
-		base:::q(save = save, status = status, runLast = runLast)
+		base::q(save = save, status = status, runLast = runLast)
 	}
 }
 
diff --git a/rkward/rbackend/rpackages/rkward/R/internal.R b/rkward/rbackend/rpackages/rkward/R/internal.R
index 739b2c518..ba524c1a8 100755
--- a/rkward/rbackend/rpackages/rkward/R/internal.R
+++ b/rkward/rbackend/rpackages/rkward/R/internal.R
@@ -157,6 +157,7 @@
 
 # Gather status information on installed and available packages.
 # Return value is used in class RKRPackageInstallationStatus of the frontend
+#' @importFrom utils installed.packages new.packages
 #' @export
 ".rk.get.package.installation.state" <- function () {
 	# fetch all status information
@@ -183,6 +184,7 @@
 
 # package information formats may - according to the help - be subject to change. Hence this function to cope with "missing" values
 # also it concatenates everything to a single vector, so we can easily get the whole structure with a single call
+#' @importFrom utils installed.packages
 #' @export
 ".rk.get.installed.packages" <- function () {
 	x <- as.data.frame(installed.packages(fields="Title"))
@@ -200,6 +202,7 @@
 }
 
 # This function works like available.packages (with no arguments), but does simple caching of the result, and of course uses a cache if available. Cache is only used, if it is less than 1 hour old, and options("repos") is unchanged.
+#' @importFrom utils available.packages
 #' @export
 ".rk.cached.available.packages" <- function () {
 	x <- NULL
@@ -281,6 +284,7 @@
 	cat (x, file = rk.get.output.html.file(), append = TRUE)
 }
 
+#' @importFrom utils URLencode
 #' @export
 ".rk.rerun.plugin.link" <- function (plugin, settings, label) {
 	.rk.cat.output (paste ("<a href=\"rkward://runplugin/", plugin, "/", URLencode (settings), "\">", label, "</a>", sep=""))
@@ -307,6 +311,9 @@ assign(".rk.shadow.envs", new.env(parent=emptyenv()), envir=.rk.variables)
 # so we have a separate function for that.
 #' @export
 ".rk.fix.assignments" <- function () {
+	# define dummy objects to satisfy R CMD check
+	choices <- preselect <- multiple <- title <- graphics <- NULL
+
 	## History manipulation function (overloads for functions by the same name in package utils)
 	rk.replace.function ("loadhistory",  as.environment ("package:utils"),
 		function (file = ".Rhistory") {
@@ -329,12 +336,8 @@ assign(".rk.shadow.envs", new.env(parent=emptyenv()), envir=.rk.variables)
 	## Interactive menus
 	rk.replace.function ("select.list", as.environment ("package:utils"), 
 		function () {
-			# the "list" parameter was renamed to "choices" in R 2.11.0
-			if (!exists ("list", inherits=FALSE)) list <- choices
-			# the "graphics" parameter was introduced in R 2.11.0, so we cannot rely on its existance
-			if (!exists ("graphics", inherits=FALSE)) graphics <- TRUE
 			if (graphics) {
-				return (rk.select.list (list, preselect, multiple, title))
+				return (rk.select.list (choices, preselect, multiple, title))
 			}
 
 			# for text list, use the default implementation
diff --git a/rkward/rbackend/rpackages/rkward/R/internal_debugger.R b/rkward/rbackend/rpackages/rkward/R/internal_debugger.R
index 1f4eceb07..49ce331c0 100644
--- a/rkward/rbackend/rpackages/rkward/R/internal_debugger.R
+++ b/rkward/rbackend/rpackages/rkward/R/internal_debugger.R
@@ -4,6 +4,7 @@
 # SPDX-License-Identifier: GPL-2.0-or-later
 # gather debug information.
 # Note: subsequent browser() calls should be suppressed while inside this function!
+#' @importFrom utils capture.output
 #' @export
 .rk.callstack.info <- function () {
 	nframes <- sys.nframe() - 1	# strip this function call
diff --git a/rkward/rbackend/rpackages/rkward/R/internal_graphics.R b/rkward/rbackend/rpackages/rkward/R/internal_graphics.R
index 7a9d33389..96225ec56 100644
--- a/rkward/rbackend/rpackages/rkward/R/internal_graphics.R
+++ b/rkward/rbackend/rpackages/rkward/R/internal_graphics.R
@@ -11,6 +11,7 @@
 #'
 #' @seealso \link{dev.new}, \link{RK}, \link{rk.embed.device}
 #'
+#' @importFrom grDevices dev.new
 #' @export
 "rk.screen.device" <- function (...) {
 	warning ("rk.screen.device() is obsolete.\nUse one of dev.new(), RK(), or rk.embed.device(), instead.")
@@ -28,6 +29,8 @@
 #' @include internal.R
 assign(".rk.preview.devices", list (), envir=.rk.variables)
 
+#' @importFrom grDevices dev.cur dev.new dev.set
+#' @importFrom graphics par
 #' @export
 ".rk.startPreviewDevice" <- function (x) {
 	# NOTE: I considered rewriting this to use .rk.create.preview.data(), but it did not seem right
@@ -50,6 +53,7 @@ assign(".rk.preview.devices", list (), envir=.rk.variables)
 	as.integer (dev.cur ())
 }
 
+#' @importFrom grDevices dev.list dev.off
 #' @export
 ".rk.killPreviewDevice" <- function (x) {
 	a <- .rk.variables$.rk.preview.devices[[x]]
@@ -78,6 +82,8 @@ assign(".rk.preview.devices", list (), envir=.rk.variables)
 .rk.variables$.rk.printer.devices <- list ()
 
 # see .rk.fix.assignmetns () in internal.R
+#' @importFrom grDevices dev.cur dev.new
+#' @importFrom utils compareVersion
 #' @export
 ".rk.fix.assignments.graphics" <- function ()
 {
@@ -93,17 +99,17 @@ assign(".rk.preview.devices", list (), envir=.rk.variables)
 				rk.record.plot$onDelDevice (devId = which)
 			
 			# see http://thread.gmane.org/gmane.comp.statistics.rkward.devel/802
-			rkward:::.rk.do.call ("killDevice", as.character (which))
+			.rk.do.call ("killDevice", as.character (which))
 			
 			ret <- eval (body (.rk.backups$dev.off))
 
 			printfile <- .rk.variables$.rk.printer.devices[[as.character (which)]]
 			if (!is.null (printfile)) {
-				rkward:::.rk.do.plain.call ("printPreview", printfile, FALSE)
+				.rk.do.plain.call ("printPreview", printfile, FALSE)
 				.rk.variables$.rk.printer.devices[[as.character (which)]] <- NULL
 			}
 
-			rkward:::.rk.discard.preview.device.num(which)
+			.rk.discard.preview.device.num(which)
 
 			return (ret)
 		})
@@ -119,23 +125,25 @@ assign(".rk.preview.devices", list (), envir=.rk.variables)
 		})
 
 	## set a hook defining "print.function" for lattice:
-	setHook (packageEvent ("lattice", "onLoad"),
-		function (...)
-			lattice::lattice.options (print.function = function (x, ...)
-			{
-				if (dev.cur() == 1) dev.new ()
-				## TODO: use "trellis" instead of "lattice" to accomodate ggplot2 plots?
-				plot_hist_enabled <- getOption ("rk.enable.graphics.history")
-				if (plot_hist_enabled) {
-					rk.record.plot$record (nextplot.pkg = "lattice")
-				}
-				rk.without.plot.history (plot (x, ...))
-				if (plot_hist_enabled) {
-					rk.record.plot$.save.tlo.in.hP ()
-				}
-				invisible ()
-			})
-	)
+	if (requireNamespace("lattice", quietly = TRUE)) {
+		setHook (packageEvent ("lattice", "onLoad"),
+			function (...)
+				lattice::lattice.options (print.function = function (x, ...)
+				{
+					if (dev.cur() == 1) dev.new ()
+					## TODO: use "trellis" instead of "lattice" to accomodate ggplot2 plots?
+					plot_hist_enabled <- getOption ("rk.enable.graphics.history")
+					if (plot_hist_enabled) {
+						rk.record.plot$record (nextplot.pkg = "lattice")
+					}
+					rk.without.plot.history (plot (x, ...))
+					if (plot_hist_enabled) {
+						rk.record.plot$.save.tlo.in.hP ()
+					}
+					invisible ()
+				})
+		)
+	}
 
 	if (compareVersion (as.character (getRversion ()), "2.14.0") < 0) {
 		setHook (packageEvent ("grid", "attach"),
diff --git a/rkward/rbackend/rpackages/rkward/R/internal_help.R b/rkward/rbackend/rpackages/rkward/R/internal_help.R
index bb8ed0a02..ba3f6cdbf 100644
--- a/rkward/rbackend/rpackages/rkward/R/internal_help.R
+++ b/rkward/rbackend/rpackages/rkward/R/internal_help.R
@@ -5,6 +5,7 @@
 ## Internal functions related to help search / display
 
 # retrieve the (expected) "base" url of help files. Most importantly this will be a local port for R 2.10.0 and above, but a local directory for 2.9.x and below. As a side effect, in R 2.10.0 and above, the dynamic help server is started.
+#' @importFrom utils compareVersion
 #' @export
 ".rk.getHelpBaseUrl" <- function () {
 	port <- NA
@@ -26,6 +27,7 @@
 
 # a simple wrapper around help() that makes it easier to detect in code, whether help was found or not.
 # used from RKHelpSearchWindow::getFunctionHelp
+#' @importFrom utils help
 #' @export
 ".rk.getHelp" <- function (topic, package=NULL, ...) {
 	res <- help (topic, (package), ..., help_type="html")
@@ -44,6 +46,7 @@
 }
 
 # Simple wrapper around help.search. Concatenates the relevant fields of the results in order for passing to the frontend.
+#' @importFrom utils help.search
 #' @export
 ".rk.get.search.results" <- function (pattern, ...) {
 	H = as.data.frame(help.search(pattern, ...)$matches)
diff --git a/rkward/rbackend/rpackages/rkward/R/public_graphics.R b/rkward/rbackend/rpackages/rkward/R/public_graphics.R
index ab4a7c984..b9ed66fe8 100644
--- a/rkward/rbackend/rpackages/rkward/R/public_graphics.R
+++ b/rkward/rbackend/rpackages/rkward/R/public_graphics.R
@@ -23,11 +23,9 @@
 #' 
 #' @author Thomas Friedrichsmeier \email{rkward-devel@@kde.org}
 #' 
-#' @seealso \link{rk.results} \link{rk.print} \link{rk.get.output.html.file} \link{dev.off} \link{svg} \link{png} \link{jpg}
+#' @seealso \code{\link{rk.results}}, \code{\link{rk.print}}, \code{\link{rk.get.output.html.file}}, \code{\link[grDevices:dev.off]{dev.off}}, \code{\link[grDevices:svg]{svg}}, \code{\link[grDevices:png]{png}}, \code{\link[grDevices:jpeg]{jpeg}}
 #'
 #' @examples
-#' require (rkward)
-#' 
 #' ## Plot directly to the output (html) file, by-passing screen device:
 #' rk.graph.on ("JPG", 480, 480, 75)
 #' plot (rnorm (100))
@@ -44,6 +42,7 @@
 #'
 #' @keywords devices
 #'
+#' @importFrom grDevices dev.cur png jpeg
 #' @export
 #' @aliases rk.graph.on rk.graph.off
 #' @rdname rk.graph.on
@@ -82,7 +81,7 @@
 			"\" height=\"", height, "\"><br>", sep = ""))
 	} else if (device.type == "SVG") {
 		if (!capabilities ("cairo")) {	# cairo support is not always compiled in
-			require (cairoDevice)
+			requireNamespace ("cairoDevice")
 			svg <- Cairo_svg
 		}
 		filename <- rk.get.tempfile.name(prefix = "graph", extension = ".svg")
@@ -101,6 +100,7 @@
 
 #' \code{rk.graph.off()} closes the device that was opened by \code{rk.graph.on}. 
 #'
+#' @importFrom grDevices dev.off dev.list dev.set
 #' @rdname rk.graph.on
 #' @export
 "rk.graph.off" <- function(){
@@ -131,6 +131,7 @@
 #'
 #' @keywords devices
 #'
+#' @importFrom grDevices dev.cur
 #' @export
 #' @aliases RK
 #' @rdname RKdevice
@@ -163,6 +164,7 @@
 #' rk.embed.device (grDevices::X11(title="X11 device window"))
 #' plot (rnorm (10))
 #'
+#' @importFrom grDevices dev.cur
 #' @export
 "rk.embed.device" <- function (expr) {
 	oldd <- dev.cur ()
@@ -184,7 +186,10 @@
 }
 
 # Internal function to create wrapper around an R device function (used for X11(), windows(), and quartz()).
+#' @importFrom utils getFromNamespace
 ".rk.make.device.wrapper" <- function (devicename) {
+	# dummy objects to satisfy R CMD check
+	bg <- title <- antialias <- NULL
 	ret <- eval (substitute (
 		function (width=getOption("rk.screendevice.width"), height=getOption("rk.screendevice.height"), pointsize=12) {
 			rk.mode <- getOption ("rk.override.platform.devices")
@@ -205,14 +210,16 @@
 				if (!is.numeric (width)) width <- 7
 				if (missing (height)) height <- getOption ("rk.screendevice.height")
 				if (!is.numeric (height)) height <- 7
-				rk.embed.device (eval (body (grDevices::devicename)))
+				# rk.embed.device (eval (body (grDevices::devicename)))
+				rk.embed.device (eval (body (getFromNamespace (devicename, ns="grDevices"))))
 			} else {
-				eval (body (grDevices::devicename))
+				# eval (body (grDevices::devicename))
+				eval (body (getFromNamespace (devicename, ns="grDevices")))
 			}
 		}
 	))
 	if (exists (devicename, envir=asNamespace ("grDevices"), inherits=FALSE)) {
-		devfun <- get (devicename, asNamespace ("grDevices"))
+		devfun <- getFromNamespace (devicename, ns="grDevices")
 		formals (ret) <- formals (devfun)
 		environment (ret) <- environment (devfun)
 	}
@@ -262,6 +269,7 @@
 #' @keywords utilities device
 #' @rdname rk.printer.device
 #' @export
+#' @importFrom grDevices dev.cur postscript
 #' @examples
 #' 
 #' ## Not run:
@@ -277,6 +285,7 @@
 	.rk.variables$.rk.printer.devices[[as.character (dev.cur ())]] <- tf
 }
 
+#' @importFrom grDevices dev.cur dev.set dev.copy dev.new
 #' @export
 "rk.duplicate.device" <- function (devId = dev.cur ())
 {
@@ -1000,42 +1009,49 @@ rk.record.plot <- rk.record.plot ()
 	options ("rk.enable.graphics.history" = x)
 	invisible ()
 }
+#' @importFrom grDevices dev.cur
 #' @export
 "rk.first.plot" <- function (devId = dev.cur ())
 {
 	if (!getOption ("rk.enable.graphics.history")) return (invisible ())
 	rk.record.plot$showFirst (devId)
 }
+#' @importFrom grDevices dev.cur
 #' @export
 "rk.previous.plot" <- function (devId = dev.cur ())
 {
 	if (!getOption ("rk.enable.graphics.history")) return (invisible ())
 	rk.record.plot$showPrevious (devId)
 }
+#' @importFrom grDevices dev.cur
 #' @export
 "rk.next.plot" <- function (devId = dev.cur ())
 {
 	if (!getOption ("rk.enable.graphics.history")) return (invisible ())
 	rk.record.plot$showNext (devId)
 }
+#' @importFrom grDevices dev.cur
 #' @export
 "rk.last.plot" <- function (devId = dev.cur ())
 {
 	if (!getOption ("rk.enable.graphics.history")) return (invisible ())
 	rk.record.plot$showLast (devId)
 }
+#' @importFrom grDevices dev.cur
 #' @export
 "rk.goto.plot" <- function (devId = dev.cur (), index=1)
 {
 	if (!getOption ("rk.enable.graphics.history")) return (invisible ())
 	rk.record.plot$showPlot (devId, index)
 }
+#' @importFrom grDevices dev.cur
 #' @export
 "rk.force.append.plot" <- function (devId = dev.cur ())
 {
 	if (!getOption ("rk.enable.graphics.history")) return (invisible ())
 	rk.record.plot$forceAppend (devId)
 }
+#' @importFrom grDevices dev.cur
 #' @export
 "rk.removethis.plot" <- function (devId = dev.cur ())
 {
@@ -1048,6 +1064,7 @@ rk.record.plot <- rk.record.plot ()
 	if (!getOption ("rk.enable.graphics.history")) return (invisible ())
 	rk.record.plot$clearHistory ()
 }
+#' @importFrom grDevices dev.cur
 #' @export
 "rk.show.plot.info" <- function (devId = dev.cur ())
 {
diff --git a/rkward/rbackend/rpackages/rkward/R/rk.KDE_GUI-functions.R b/rkward/rbackend/rpackages/rkward/R/rk.KDE_GUI-functions.R
index 4df464741..bff7057a4 100755
--- a/rkward/rbackend/rpackages/rkward/R/rk.KDE_GUI-functions.R
+++ b/rkward/rbackend/rpackages/rkward/R/rk.KDE_GUI-functions.R
@@ -50,7 +50,7 @@
 #'   if the user simply presses enter.
 #' @param wait a logical (not NA) indicating whether the R interpreter should
 #'   wait for the user's action, or run it asynchronously.
-#' @param list a vector, coerced into a character vector.
+#' @param choices a vector, coerced into a character vector.
 #' @param preselct a vector, coerced into a character vector, items to be
 #'   preselected.
 #' @param multiple a logical (not NA), when \code{TRUE} multiple selection
@@ -80,9 +80,6 @@
 #' @keywords utilities
 #' @rdname rk.show.messages
 #' @examples
-#' 
-#' require (rkward)
-#' 
 #' ## Message boxes
 #' if (rk.show.question ("Question:\nDo you want to know about RKWard?", 
 #'     button.yes = "Yes, I do!", button.no = "No, I don't care!", button.cancel = "")) {
@@ -174,15 +171,15 @@
 # drop-in-replacement for tk_select.list()
 #' @export
 #' @rdname rk.show.messages
-"rk.select.list" <- function (list, preselect, multiple = FALSE, title) {
+"rk.select.list" <- function (choices, preselect, multiple = FALSE, title) {
     if (missing (preselect)) {
         preselect <- character(0)
     } else {
         preselect <- as.character (preselect)
     }
 	preselect.len = length (preselect)
-	list <- as.character (list)
-	list.len <- length (list)
+	choices <- as.character (choices)
+	choices.len <- length (choices)
 	params <- list ()
 
 	# serialize all parameters
@@ -195,9 +192,9 @@
 			params[3+i] <- preselect[i]
 		}
 	}
-	if (list.len) {	# we should hope, the list is not empty...
-		for (i in 1:list.len) {
-			params[3+preselect.len+i] <- list[i]
+	if (choices.len) {	# we should hope, the list is not empty...
+		for (i in 1:choices.len) {
+			params[3+preselect.len+i] <- choices[i]
 		}
 	}
 
diff --git a/rkward/rbackend/rpackages/rkward/R/rk.plugin-functions.R b/rkward/rbackend/rpackages/rkward/R/rk.plugin-functions.R
index c6181ee5c..948ac6e65 100644
--- a/rkward/rbackend/rpackages/rkward/R/rk.plugin-functions.R
+++ b/rkward/rbackend/rpackages/rkward/R/rk.plugin-functions.R
@@ -98,7 +98,7 @@
 #'              Any currently opened plugins are not affected by this function. 
 #'
 #' @author Thomas Friedrichsmeier \email{rkward-devel@@kde.org}
-#' @seealso \code{\link{rk.call.plugin}}, @seealso \code{\link{rkwarddev::rk.plugin.skeleton}}
+#' @seealso \code{\link{rk.call.plugin}}, \code{\link[rkwarddev:rk.plugin.skeleton]{rk.plugin.skeleton}}
 #' @keywords utilities
 #'
 #' @examples
diff --git a/rkward/rbackend/rpackages/rkward/R/rk.print-functions.R b/rkward/rbackend/rpackages/rkward/R/rk.print-functions.R
index bad0e2030..e83f46ffd 100644
--- a/rkward/rbackend/rpackages/rkward/R/rk.print-functions.R
+++ b/rkward/rbackend/rpackages/rkward/R/rk.print-functions.R
@@ -11,9 +11,9 @@
 #' \code{\link{rk.graph.on}} can be used to create a HTML report.
 #' 
 #' \code{rk.print} prints/exports the given object to the output (html) file
-#' using the \code{\link{HTML}} function. This requires the \code{R2HTML}
+#' using the \code{\link[R2HTML:HTML]{HTML}} function. This requires the \code{R2HTML}
 #' package. Additional arguments in \code{...} are passed on to
-#' \code{\link{HTML}}. For some types of objects (e.g. "htmlwidgets" from
+#' \code{\link[R2HTML:HTML]{HTML}}. For some types of objects (e.g. "htmlwidgets" from
 #' the "htmlwidgets" package) additional packages may be required.
 #' 
 #' \code{rk.print.literal} prints/exports the given object using a
@@ -54,61 +54,62 @@
 #' @return \code{rk.describe.alternatives} returns a string while all other
 #'   functions return \code{NULL}, invisibly.
 #' @author Thomas Friedrichsmeier \email{rkward-devel@@kde.org}
-#' @seealso \code{\link{HTML}}, \code{\link{rk.get.output.html.file}},
+#' @seealso \code{\link[R2HTML:HTML]{HTML}}, \code{\link{rk.get.output.html.file}},
 #'   \code{\link{rk.get.description}}, \code{\link{rk.call.plugin}},
 #'   \url{rkward://page/rkward_output}
 #' @keywords utilities
 #' @rdname rk.results
 #' @examples
 #' 
-#' require (rkward)
-#' require (R2HTML)
+#' # code is only run when the R2HTML package can be loaded
+#' if(require("R2HTML", quietly = TRUE)){
 #' 
-#' ## see the output: Windows->Show Output
-#' ## stolen from the two-sample t-test plugin ;)
-#' local({
-#' x1 <- rnorm (100)
-#' x2 <- rnorm (100, 2)
-#' nm <- rk.get.description (x1,x2)
+#'   ## see the output: Windows->Show Output
+#'   ## stolen from the two-sample t-test plugin ;)
+#'   local({
+#'   x1 <- rnorm (100)
+#'   x2 <- rnorm (100, 2)
+#'   nm <- rk.get.description (x1,x2)
 #' 
-#' result <- t.test (x1, x2, alternative="less")
-#' rk.print.code ("result <- t.test (x1, x2, alternative=\"less\")")
+#'   result <- t.test (x1, x2, alternative="less")
+#'   rk.print.code ("result <- t.test (x1, x2, alternative=\"less\")")
 #' 
-#' rk.header (result$method,
-#'   parameters=list ("Comparing", paste (nm[1], "against", nm[2]),
-#'   "H1", rk.describe.alternative (result),
-#'   "Equal variances", "not assumed"))
+#'   rk.header (result$method,
+#'     parameters=list ("Comparing", paste (nm[1], "against", nm[2]),
+#'     "H1", rk.describe.alternative (result),
+#'     "Equal variances", "not assumed"))
 #' 
-#' rk.print.literal ("Raw data (first few rows):")
-#' rk.print (head (cbind (x1,x2)), align = "left")
-#' 
-#' rk.print.literal ("Test results:")
-#' rk.results (list (
-#'   'Variable Name'=nm,
-#'   'estimated mean'=result$estimate,
-#'   'degrees of freedom'=result$parameter,
-#'   t=result$statistic,
-#'   p=result$p.value,
-#'   'confidence interval percent'=(100 * attr(result$conf.int, "conf.level")),
-#'   'confidence interval of difference'=result$conf.int ))
-#' })
+#'   rk.print.literal ("Raw data (first few rows):")
+#'   rk.print (head (cbind (x1,x2)), align = "left")
 #' 
+#'   rk.print.literal ("Test results:")
+#'   rk.results (list (
+#'     'Variable Name'=nm,
+#'     'estimated mean'=result$estimate,
+#'     'degrees of freedom'=result$parameter,
+#'     t=result$statistic,
+#'     p=result$p.value,
+#'     'confidence interval percent'=(100 * attr(result$conf.int, "conf.level")),
+#'     'confidence interval of difference'=result$conf.int ))
+#'   })
+#' } else {}
+#' @importFrom grDevices dev.cur
 #' @export
 "rk.print" <- function(x,...) {
 	if (inherits (x, "htmlwidget")) {
-		require ("htmlwidgets")
+		requireNamespace ("htmlwidgets", quietly = TRUE)
 		name <- deparse (substitute (x))
 		filename <- rk.get.tempfile.name (name, ".html")
 		dir <- rk.get.tempfile.name (name, "_data")
-		saveWidget (x, filename, selfcontained=FALSE, libdir=dir)
+		htmlwidget::saveWidget (x, filename, selfcontained=FALSE, libdir=dir)
 		.rk.cat.output (paste0 ("<object width=\"100%\" height=\"100%\" data=\"file://", filename, "\" onload=\"this.style.height = this.contentWindow.document.body.scrollHeight + 'px';\"></object>"))
 	} else if (inherits (x, "gvis")) {
-		require ("googleVis")
+		requireNamespace ("googleVis", quietly = TRUE)
 		print (x, file=rk.get.output.html.file(), append=TRUE)
 	} else {
 		htmlfile <- rk.get.output.html.file()
-		if(require("R2HTML")==TRUE) {
-			HTML(x, file=htmlfile,...)
+		if(requireNamespace ("R2HTML", quietly = TRUE)) {
+			R2HTML::HTML(x, file=htmlfile,...)
 		}
 	}
 }
diff --git a/rkward/rbackend/rpackages/rkward/R/rk.sessionInfo.R b/rkward/rbackend/rpackages/rkward/R/rk.sessionInfo.R
index 7421f27ca..c65a3bb14 100644
--- a/rkward/rbackend/rpackages/rkward/R/rk.sessionInfo.R
+++ b/rkward/rbackend/rpackages/rkward/R/rk.sessionInfo.R
@@ -16,6 +16,7 @@
 #' @author Thomas Friedrichsmeier \email{rkward-devel@@kde.org}
 #' @seealso \code{\link{sessionInfo}}
 #' @keywords utilities misc
+#' @importFrom utils sessionInfo
 #' @export
 #' @rdname rk.sessionInfo
 #' @examples
diff --git a/rkward/rbackend/rpackages/rkward/R/rk.utility-functions.R b/rkward/rbackend/rpackages/rkward/R/rk.utility-functions.R
index f92bb9446..53315a14f 100644
--- a/rkward/rbackend/rpackages/rkward/R/rk.utility-functions.R
+++ b/rkward/rbackend/rpackages/rkward/R/rk.utility-functions.R
@@ -53,7 +53,7 @@
 		}
 		i = i+1;
 	}
-	error ("Could not find column with given name")
+	stop ("Could not find column with given name")
 }
 
 #' @export
@@ -80,6 +80,7 @@
 }
 
 # a wrapper around chooseCRANmirror() without changing options ("repos"), permanently
+#' @importFrom utils getCRANmirrors menu
 #' @export
 #' @rdname rk.misc
 "rk.select.CRAN.mirror" <- function () {
@@ -115,10 +116,10 @@
 #' @keywords attribute misc utilities
 #' @rdname rk.old.packages
 #' @examples
-#' 
-#' ## NOT RUN
+#' \dontrun{
 #' rk.old.packages()
-#' 
+#' }
+#' @importFrom utils contrib.url installed.packages old.packages
 #' @export
 "rk.old.packages" <- function (lib.loc = NULL, repos = getOption("repos"), contriburl = contrib.url(repos, type), instPkgs = installed.packages(lib.loc = lib.loc),
                              method, available, checkBuilt = FALSE, type = getOption("pkgType")) {
diff --git a/rkward/rbackend/rpackages/rkward/R/rk.workspace-functions.R b/rkward/rbackend/rpackages/rkward/R/rk.workspace-functions.R
index 7f43b387e..6193f6852 100644
--- a/rkward/rbackend/rpackages/rkward/R/rk.workspace-functions.R
+++ b/rkward/rbackend/rpackages/rkward/R/rk.workspace-functions.R
@@ -32,12 +32,12 @@
 #' @keywords utilities
 #' @rdname rk.workplace
 #' @examples
-#' 
-#' ## Not run
+#' \dontrun{
 #' rk.save.workplace ()
 #' rk.restore.workplace ()
-#' ## End not run
+#' }
 #' 
+#' @importFrom utils URLdecode
 #' @export
 "rk.save.workplace" <- function (file, description) {
 	if (missing (file)) {
@@ -52,6 +52,7 @@
 }
 
 #' @rdname rk.workplace
+#' @importFrom utils URLdecode
 #' @export
 "rk.restore.workplace" <- function (file, close.windows=TRUE) {
 	if (missing (file)) {
diff --git a/rkward/rbackend/rpackages/rkward/man/rk.graph.on.Rd b/rkward/rbackend/rpackages/rkward/man/rk.graph.on.Rd
index 772d4281e..b965ef9b6 100644
--- a/rkward/rbackend/rpackages/rkward/man/rk.graph.on.Rd
+++ b/rkward/rbackend/rpackages/rkward/man/rk.graph.on.Rd
@@ -36,8 +36,6 @@ The default is to use the quality configured in Settings -> Configure RKWard ->
 The default settings for \code{device.type}, \code{width}, \code{height}, and \code{quality} can be modified from Settings -> Configure RKWard -> Output.
 }
 \examples{
-require (rkward)
-
 ## Plot directly to the output (html) file, by-passing screen device:
 rk.graph.on ("JPG", 480, 480, 75)
 plot (rnorm (100))
@@ -54,7 +52,7 @@ rk.graph.off ()
 
 }
 \seealso{
-\link{rk.results} \link{rk.print} \link{rk.get.output.html.file} \link{dev.off} \link{svg} \link{png} \link{jpg}
+\code{\link{rk.results}}, \code{\link{rk.print}}, \code{\link{rk.get.output.html.file}}, \code{\link[grDevices:dev.off]{dev.off}}, \code{\link[grDevices:svg]{svg}}, \code{\link[grDevices:png]{png}}, \code{\link[grDevices:jpeg]{jpeg}}
 }
 \author{
 Thomas Friedrichsmeier \email{rkward-devel at kde.org}
diff --git a/rkward/rbackend/rpackages/rkward/man/rk.load.pluginmaps.Rd b/rkward/rbackend/rpackages/rkward/man/rk.load.pluginmaps.Rd
index b98dba180..d50da04da 100644
--- a/rkward/rbackend/rpackages/rkward/man/rk.load.pluginmaps.Rd
+++ b/rkward/rbackend/rpackages/rkward/man/rk.load.pluginmaps.Rd
@@ -37,7 +37,7 @@ rk.load.pluginmaps()
 ## END NOT RUN
 }
 \seealso{
-\code{\link{rk.call.plugin}}, @seealso \code{\link{rkwarddev::rk.plugin.skeleton}}
+\code{\link{rk.call.plugin}}, \code{\link[rkwarddev:rk.plugin.skeleton]{rk.plugin.skeleton}}
 }
 \author{
 Thomas Friedrichsmeier \email{rkward-devel at kde.org}
diff --git a/rkward/rbackend/rpackages/rkward/man/rk.old.packages.Rd b/rkward/rbackend/rpackages/rkward/man/rk.old.packages.Rd
index 6b24df2ec..bda929921 100644
--- a/rkward/rbackend/rpackages/rkward/man/rk.old.packages.Rd
+++ b/rkward/rbackend/rpackages/rkward/man/rk.old.packages.Rd
@@ -27,10 +27,9 @@ old.packages() will report package X at B as old. In contrast rk.old.packages()
 that the current version is higher up in the path, and not report package X as old.
 }
 \examples{
-
-## NOT RUN
+\dontrun{
 rk.old.packages()
-
+}
 }
 \author{
 Thomas Friedrichsmeier \email{rkward-devel at kde.org}
diff --git a/rkward/rbackend/rpackages/rkward/man/rk.results.Rd b/rkward/rbackend/rpackages/rkward/man/rk.results.Rd
index 867433934..47b19a262 100644
--- a/rkward/rbackend/rpackages/rkward/man/rk.results.Rd
+++ b/rkward/rbackend/rpackages/rkward/man/rk.results.Rd
@@ -59,9 +59,9 @@ Output. Basically, these functions along with the ones described in
 }
 \details{
 \code{rk.print} prints/exports the given object to the output (html) file
-using the \code{\link{HTML}} function. This requires the \code{R2HTML}
+using the \code{\link[R2HTML:HTML]{HTML}} function. This requires the \code{R2HTML}
 package. Additional arguments in \code{...} are passed on to
-\code{\link{HTML}}. For some types of objects (e.g. "htmlwidgets" from
+\code{\link[R2HTML:HTML]{HTML}}. For some types of objects (e.g. "htmlwidgets" from
 the "htmlwidgets" package) additional packages may be required.
 
 \code{rk.print.literal} prints/exports the given object using a
@@ -83,41 +83,41 @@ sense only when \code{x$alternatives} exists.
 }
 \examples{
 
-require (rkward)
-require (R2HTML)
-
-## see the output: Windows->Show Output
-## stolen from the two-sample t-test plugin ;)
-local({
-x1 <- rnorm (100)
-x2 <- rnorm (100, 2)
-nm <- rk.get.description (x1,x2)
-
-result <- t.test (x1, x2, alternative="less")
-rk.print.code ("result <- t.test (x1, x2, alternative=\"less\")")
-
-rk.header (result$method,
-  parameters=list ("Comparing", paste (nm[1], "against", nm[2]),
-  "H1", rk.describe.alternative (result),
-  "Equal variances", "not assumed"))
-
-rk.print.literal ("Raw data (first few rows):")
-rk.print (head (cbind (x1,x2)), align = "left")
-
-rk.print.literal ("Test results:")
-rk.results (list (
-  'Variable Name'=nm,
-  'estimated mean'=result$estimate,
-  'degrees of freedom'=result$parameter,
-  t=result$statistic,
-  p=result$p.value,
-  'confidence interval percent'=(100 * attr(result$conf.int, "conf.level")),
-  'confidence interval of difference'=result$conf.int ))
-})
-
+# code is only run when the R2HTML package can be loaded
+if(require("R2HTML", quietly = TRUE)){
+
+  ## see the output: Windows->Show Output
+  ## stolen from the two-sample t-test plugin ;)
+  local({
+  x1 <- rnorm (100)
+  x2 <- rnorm (100, 2)
+  nm <- rk.get.description (x1,x2)
+
+  result <- t.test (x1, x2, alternative="less")
+  rk.print.code ("result <- t.test (x1, x2, alternative=\"less\")")
+
+  rk.header (result$method,
+    parameters=list ("Comparing", paste (nm[1], "against", nm[2]),
+    "H1", rk.describe.alternative (result),
+    "Equal variances", "not assumed"))
+
+  rk.print.literal ("Raw data (first few rows):")
+  rk.print (head (cbind (x1,x2)), align = "left")
+
+  rk.print.literal ("Test results:")
+  rk.results (list (
+    'Variable Name'=nm,
+    'estimated mean'=result$estimate,
+    'degrees of freedom'=result$parameter,
+    t=result$statistic,
+    p=result$p.value,
+    'confidence interval percent'=(100 * attr(result$conf.int, "conf.level")),
+    'confidence interval of difference'=result$conf.int ))
+  })
+} else {}
 }
 \seealso{
-\code{\link{HTML}}, \code{\link{rk.get.output.html.file}},
+\code{\link[R2HTML:HTML]{HTML}}, \code{\link{rk.get.output.html.file}},
   \code{\link{rk.get.description}}, \code{\link{rk.call.plugin}},
   \url{rkward://page/rkward_output}
 }
diff --git a/rkward/rbackend/rpackages/rkward/man/rk.show.messages.Rd b/rkward/rbackend/rpackages/rkward/man/rk.show.messages.Rd
index 8cdb2d90a..596dd9e66 100644
--- a/rkward/rbackend/rpackages/rkward/man/rk.show.messages.Rd
+++ b/rkward/rbackend/rpackages/rkward/man/rk.show.messages.Rd
@@ -29,7 +29,7 @@ rk.askYesNo(
   ...
 )
 
-rk.select.list(list, preselect, multiple = FALSE, title)
+rk.select.list(choices, preselect, multiple = FALSE, title)
 
 rk.select.file(
   caption,
@@ -78,7 +78,7 @@ separated by \code{/} characters.}
 via \code{options("askYesNo"=rk.askYesNo)} because otherwise we'd either need more
 complicated function code there, fail with an error or end up in an infinite loop.}
 
-\item{list}{a vector, coerced into a character vector.}
+\item{choices}{a vector, coerced into a character vector.}
 
 \item{multiple}{a logical (not NA), when \code{TRUE} multiple selection
 selection is allowed.}
@@ -138,9 +138,6 @@ they expect. In those cases, the name of the target directory must be entered in
 input field of the dialog manually.
 }
 \examples{
-
-require (rkward)
-
 ## Message boxes
 if (rk.show.question ("Question:\nDo you want to know about RKWard?", 
     button.yes = "Yes, I do!", button.no = "No, I don't care!", button.cancel = "")) {
diff --git a/rkward/rbackend/rpackages/rkward/man/rk.workplace.Rd b/rkward/rbackend/rpackages/rkward/man/rk.workplace.Rd
index c8700c293..acadd41f7 100644
--- a/rkward/rbackend/rpackages/rkward/man/rk.workplace.Rd
+++ b/rkward/rbackend/rpackages/rkward/man/rk.workplace.Rd
@@ -40,11 +40,10 @@ device windows will not be restored (but WILL be closed by
 \code{rk.restore.workplace()}, if \code{close.windows} is TRUE).
 }
 \examples{
-
-## Not run
+\dontrun{
 rk.save.workplace ()
 rk.restore.workplace ()
-## End not run
+}
 
 }
 \seealso{



More information about the rkward-tracker mailing list