Skip to content

Commit d7aa0c4

Browse files
committed
change plotting settings
1 parent 9e9d184 commit d7aa0c4

34 files changed

Lines changed: 162 additions & 99 deletions

R/FDboostLSS.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,12 @@
121121
#' m_boost <- m_boost[mstop(cvr)] ## 832
122122
#'
123123
#' ## plot smooth effects of functional covariates for mu and sigma
124-
#' par(mfrow = c(1,2))
124+
#' oldpar <- par(mfrow = c(1,2))
125125
#' plot(m_boost$mu, which = 2, ylim = c(0,5))
126126
#' lines(s, sin(s*pi)*5, col = 3, lwd = 2)
127127
#' plot(m_boost$sigma, which = 2, ylim = c(-2.5,2.5))
128128
#' lines(s, -cos(s*pi)*2, col = 3, lwd = 2)
129+
#' par(oldpar)
129130
#' }
130131
#' }
131132
#' @export

R/baselearners.R

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
#' xind2 <- xind + 0.5
6666
#' integrationWeightsLeft(X1, xind2, leftWeight = "zero")
6767
#'
68+
#' @return Matrix with integration
6869
#' @export
6970
#################################
7071
# Trapezoidal integration weights for a functional variable X1 on grid xind
@@ -573,9 +574,8 @@ X_bsignal <- function(mf, vary, args) {
573574
#' + bsignal(NIR, nir.lambda, knots = 40, df=4, check.ident = FALSE),
574575
#' timeformula = NULL, data = fuelSubset)
575576
#' summary(mod2)
576-
#' ## plot(mod2)
577-
#'
578577
#'
578+
#'
579579
#' ###############################################
580580
#' ### data simulation like in manual of pffr::ff
581581
#'
@@ -608,10 +608,11 @@ X_bsignal <- function(mf, vary, args) {
608608
#' m1_pffr <- pffr(Y ~ ff(X1, xind = s), yind = t, data = data1)
609609
#'
610610
#' \donttest{
611-
#' par(mfrow = c(2, 2))
611+
#' oldpar <- par(mfrow = c(2, 2))
612612
#' plot(m1, which = 1); plot(m1, which = 2)
613613
#' plot(m1_pffr, select = 1, shift = m1_pffr$coefficients["(Intercept)"])
614614
#' plot(m1_pffr, select = 2)
615+
#' par(oldpar)
615616
#' }
616617
#'
617618
#'
@@ -645,12 +646,12 @@ X_bsignal <- function(mf, vary, args) {
645646
#' m2_pffr <- pffr(Y ~ ff(X1, xind = s, limits = "s<=t"), yind = t, data = data2)
646647
#'
647648
#' \donttest{
648-
#' par(mfrow = c(2, 2))
649+
#' oldpar <- par(mfrow = c(2, 2))
649650
#' plot(m2, which = 1); plot(m2, which = 2)
650651
#' ## plot of smooth intercept does not contain m1_pffr$coefficients["(Intercept)"]
651652
#' plot(m2_pffr, select = 1, shift = m2_pffr$coefficients["(Intercept)"])
652653
#' plot(m2_pffr, select = 2)
653-
#'
654+
#' par(oldpar)
654655
#' }
655656
#'
656657
#'

R/bootstrapCIs.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ bootstrapCI <- function(object, which = NULL,
490490
#' @details \code{plot.bootstrapCI} plots the bootstrapped coefficients.
491491
#'
492492
#' @aliases print.bootstrapCI
493-
#'
493+
#' @return No return value (plot method) or \code{x} itself (print method)
494494
#' @method plot bootstrapCI
495495
#'
496496
#' @export

R/clr_functions.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ clr <- function(f, w = 1, inverse = FALSE) {
195195
#' # Plot densities
196196
#' year_col <- rainbow(70, start = 0.5, end = 1)
197197
#' year_lty <- c(1, 2, 4, 5)
198-
#' par(mfrow = c(1, 2))
198+
#' oldpar <- par(mfrow = c(1, 2))
199199
#' funplot(1:12, birthDistribution$birth_densities[1:70, ], ylab = "densities", xlab = "month",
200200
#' xaxp = c(1, 12, 11), pch = 20, col = year_col, lty = year_lty, main = "Male")
201201
#' funplot(1:12, birthDistribution$birth_densities[71:140, ], ylab = "densities", xlab = "month",
@@ -237,5 +237,5 @@ clr <- function(f, w = 1, inverse = FALSE) {
237237
#' xaxp = c(1, 12, 11), pch = 20, col = year_col, lty = year_lty, main = "Male")
238238
#' funplot(1:12, predictions[71:140, ], ylab = "predictions", xlab = "month", ylim = pred_ylim,
239239
#' xaxp = c(1, 12, 11), pch = 20, col = year_col, lty = year_lty, main = "Female")
240-
#' par(mfrow = c(1, 1))
240+
#' par(oldpar)
241241
"birthDistribution"

R/constrainedX.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ bl_lin_matrix_a <- function(blg, Xfun, args) {
683683
#'
684684
#' ## compare estimated coefficients
685685
#' \donttest{
686-
#' par(mfrow=c(4, 2))
686+
#' oldpar <- par(mfrow=c(4, 2))
687687
#' plot(mod1, which = 1)
688688
#' plot(mod1a, which = 1)
689689
#' plot(mod1, which = 2)
@@ -692,6 +692,7 @@ bl_lin_matrix_a <- function(blg, Xfun, args) {
692692
#' plot(mod1a, which = 3)
693693
#' funplot(mod1$yind, predict(mod1, which=4))
694694
#' funplot(mod1$yind, predict(mod1a, which=4))
695+
#' par(oldpar)
695696
#' }
696697
#'
697698
#' @name anisotropic_Kronecker

R/crossvalidation.R

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,10 @@
143143
#'
144144
#' \donttest{
145145
#' ## plot the out-of-bag risk
146-
#' par(mfrow = c(1,3))
146+
#' oldpar <- par(mfrow = c(1,3))
147147
#' plot(cvr); legend("topright", lty=2, paste(mstop(cvr)))
148148
#' plot(cvr3); legend("topright", lty=2, paste(mstop(cvr3)))
149+
#' par(oldpar)
149150
#' }
150151
#'
151152
#'}
@@ -659,7 +660,7 @@ applyFolds <- function(object, folds = cv(rep(1, length(unique(object$id))), typ
659660
#' cvr3 <- cvrisk(mod, folds = folds_bs_long, grid = 1:75)
660661
#'
661662
#' ## plot the out-of-bag risk
662-
#' par(mfrow = c(1,3))
663+
#' oldpar <- par(mfrow = c(1,3))
663664
#' plot(cvr); legend("topright", lty=2, paste(mstop(cvr)))
664665
#' plot(cvr2)
665666
#' plot(cvr3); legend("topright", lty=2, paste(mstop(cvr3)))
@@ -678,6 +679,8 @@ applyFolds <- function(object, folds = cv(rep(1, length(unique(object$id))), typ
678679
#' plotPredCoef(cvr_jackknife, which = 3)
679680
#' ## plot coefficients per fold for 2nd effect
680681
#' plotPredCoef(cvr_jackknife, which = 2, terms = FALSE)
682+
#'
683+
#' par(oldpar)
681684
#'
682685
#'}
683686
#'}
@@ -1200,6 +1203,8 @@ print.validateFDboost <- function(x, ...){
12001203
#' coefficients that were estimated in the folds - only possible if the argument getCoefCV is \code{TRUE} in
12011204
#' the call to \code{validateFDboost}.
12021205
#'
1206+
#' @return No return value (plot method) or the object itself (print method)
1207+
#'
12031208
#' @aliases mstop.validateFDboost
12041209
#'
12051210
#' @method plot validateFDboost

R/factorize.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ factorize <- factorise <- function(x, ...) {
4747
#' or for the whole model simultaneously.
4848
#'
4949
#' @method factorize FDboost
50+
#' @return A factorized model
5051
#' @export
5152
#' @rdname factorize
5253
factorize.FDboost <- function(x, newdata = NULL, newweights = 1, blwise = TRUE, ...) {
@@ -328,7 +329,8 @@ NULL
328329
#' @export
329330
#' @name predict.FDboost_fac
330331
#' @aliases plot.FDboost_fac
331-
#'
332+
#' @return A matrix of predictions (for predict method) or no
333+
#' return value (plot method)
332334
#' @seealso [factorize(), factorize.FDboost()]
333335
#'
334336
predict.FDboost_fac <- function(object, newdata = NULL, which = NULL, ...) {

R/hmatrix.R

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@
6666
#' str(mydat)
6767
#' str(mydat[id1 %in% c(2, 3), ])
6868
#' str(myhmatrix[id1 %in% c(2, 3), ])
69+
#'
70+
#' @return An matrix object of type \code{"hmatrix"}
6971
#'
7072
#' @export
7173
hmatrix <- function(time, id, x, argvals=1:ncol(x),
@@ -120,7 +122,7 @@ hmatrix <- function(time, id, x, argvals=1:ncol(x),
120122
#' @seealso \code{\link{hmatrix}} for the h.atrix class.
121123
#'
122124
#' @aliases getId getX getArgvals getTimeLab getIdLab getXLab getArgvalsLab
123-
#'
125+
#' @return properties of a hmatrix or fmatrix
124126
#' @export
125127
getTime <- function(object) { UseMethod("getTime", object) }
126128

@@ -165,6 +167,7 @@ getArgvalsLab <- function(object) { UseMethod("getArgvalsLab", object) }
165167
#' \code{getIdLab}, \code{getXLab}, \code{getArgvalsLab} for an object of class \code{hmatrix}.
166168
#'
167169
#' @aliases getId.hmatrix getX.hmatrix getArgvals.hmatrix getTimeLab.hmatrix getXLab.hmatrix getArgvalsLab.hmatrix
170+
#' @return properties of a hmatrix
168171
#'
169172
#' @export
170173
getTime.hmatrix <- function(object) object[ , 1, drop=TRUE]
@@ -203,7 +206,7 @@ getArgvalsLab.hmatrix <- function(object) attr(object, "argvalsLab")
203206
#'
204207
#' is.hmatrix tests if its argument is an object of class hmatrix.
205208
#' @param object object of class hmatrix
206-
#'
209+
#' @return logical value
207210
#' @export
208211
is.hmatrix <- function(object){
209212
inherits(object, "hmatrix")
@@ -231,7 +234,7 @@ is.hmatrix <- function(object){
231234
#' From the functional covariate \code{x} rows are selected accordingly.
232235
#'
233236
#' @seealso ?"["
234-
#'
237+
#' @return a \code{"hmatrix"} object
235238
#' @export
236239
`[.hmatrix` <- function(x, i, j, ..., drop=FALSE) {
237240

@@ -272,7 +275,7 @@ is.hmatrix <- function(object){
272275
#' repeated accordingly so that two vectors of the same length are returned.
273276
#' @param time the observation points
274277
#' @param id the id for the curve
275-
#'
278+
#' @return a list with \code{time} and \code{id}
276279
#' @export
277280
wide2long <- function(time, id){
278281
newtime <- rep(time, each=length(unique(id)))
@@ -303,6 +306,8 @@ wide2long <- function(time, id){
303306
#' try(resMat2 <- subset_hmatrix(resMat, index = index2))
304307
#' resMat <- subset_hmatrix(hmat, index = index1, compress = FALSE)
305308
#' try(resMat2 <- subset_hmatrix(resMat, index = index2))
309+
#'
310+
#' @return a \code{hmatrix} object
306311
#'
307312
#' @export
308313
subset_hmatrix <- function(x, index, compress = TRUE)

R/methods.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1373,7 +1373,7 @@ getColPersp <- function(z, col1 = "tomato", col2 = "lightblue"){
13731373
#'
13741374
#' @seealso \code{\link{FDboost}} for the model fit and
13751375
#' \code{\link{coef.FDboost}} for the calculation of the coefficient functions.
1376-
#'
1376+
#' @return no return value (plot method)
13771377
#' @method plot FDboost
13781378
#' @export
13791379
### function to plot raw values or coefficient-functions/surfaces of a model

R/utilityFunctions.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#' @param silent print error messages of model fit?
99
#' @param cyclic defaults to FALSE, if TRUE cyclic splines are used
1010
#' @param knots arguments knots passed to \code{\link[mgcv]{gam}}
11-
#'
11+
#' @return a list with controls
1212
#' @export
1313
o_control <- function(k_min=20, rule=2, silent=TRUE, cyclic=FALSE, knots=NULL) {
1414
RET <- list(k_min=k_min, rule=rule, silent=silent, cyclic=cyclic, knots=knots)
@@ -38,10 +38,11 @@ o_control <- function(k_min=20, rule=2, silent=TRUE, cyclic=FALSE, knots=NULL) {
3838
#' datTr <- truncateTime(funVar=c("hgtm","hgtf"), time="age", newtime=1:16, data=dat)
3939
#'
4040
#' \donttest{
41-
#' par(mfrow=c(1,2))
41+
#' oldpar <- par(mfrow=c(1,2))
4242
#' with(dat, funplot(age, hgtm, main="Original data"))
4343
#' with(datTr, funplot(age, hgtm, main="Yearly data"))
4444
#' par(mfrow=c(1,1))
45+
#' par(oldpar)
4546
#' }
4647
#' }
4748
#' @export
@@ -81,6 +82,7 @@ truncateTime <- function(funVar, time, newtime, data){
8182
#' with(fda::growth, funplot(age, t(hgtm)))
8283
#' }
8384
#' }
85+
#' @return see \code{\link[graphics]{matplot}}
8486
#' @export
8587
funplot <- function(x, y, id=NULL, rug=TRUE, ...){
8688

0 commit comments

Comments
 (0)