Skip to content

Commit bbf40e3

Browse files
authored
Merge pull request #42 from bbuchsbaum/codex/add-rdname-tags-and-examples-for-methods
Add rdname tags for y_train generics with examples
2 parents 8691eb5 + 6c9d139 commit bbf40e3

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

R/allgeneric.R

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,11 @@ train_model <- function(obj,...) {
339339
#' Extract the training labels or response variable from an object.
340340
#'
341341
#' @param obj The object from which to extract the training response variable.
342+
#'
343+
#' @rdname y_train-methods
344+
#' @examples
345+
#' ds <- gen_sample_dataset(D = c(4, 4, 4), nobs = 10)
346+
#' y_train(ds$design)
342347
#' @export
343348
y_train <- function(obj) {
344349
UseMethod("y_train")
@@ -349,6 +354,11 @@ y_train <- function(obj) {
349354
#' Extract the test labels or response variable from an object.
350355
#'
351356
#' @param obj The object from which to extract the test response variable.
357+
#'
358+
#' @rdname y_test-methods
359+
#' @examples
360+
#' ds <- gen_sample_dataset(D = c(4, 4, 4), nobs = 10, external_test = TRUE)
361+
#' y_test(ds$design)
352362
#' @export
353363
y_test <- function(obj) {
354364
UseMethod("y_test")
@@ -359,6 +369,11 @@ y_test <- function(obj) {
359369
#' Return the design table associated with the test set from an object.
360370
#'
361371
#' @param obj The object from which to extract the test design table.
372+
#'
373+
#' @rdname test_design-methods
374+
#' @examples
375+
#' ds <- gen_sample_dataset(D = c(4, 4, 4), nobs = 10, external_test = TRUE)
376+
#' test_design(ds$design)
362377
#' @export
363378
test_design <- function(obj) {
364379
UseMethod("test_design")

R/design.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,23 @@ nresponses.mvpa_design <- function(x) {
1919
}
2020

2121
#' @export
22+
#' has_test_set check for mvpa_design
2223
has_test_set.mvpa_design <- function(obj) {
23-
!is.null(obj$y_test)
24+
!is.null(obj$y_test)
2425
}
2526

2627

28+
#' @rdname y_train-methods
2729
#' @export
2830
y_train.mvpa_design <- function(obj) obj$y_train
2931

3032

33+
#' @rdname y_test-methods
3134
#' @export
3235
y_test.mvpa_design <- function(obj) if (is.null(obj$y_test)) obj$y_train else obj$y_test
3336

3437

38+
#' @rdname test_design-methods
3539
#' @export
3640
test_design.mvpa_design <- function(obj) {
3741
if (is.null(obj$y_test)) obj$train_design else obj$test_design

R/feature_rsa_model.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,11 +1333,13 @@ train_model.feature_rsa_model <- function(obj, X, y, indices, ...) {
13331333
}
13341334

13351335

1336+
#' @rdname y_train-methods
13361337
#' @export
13371338
y_train.feature_rsa_model <- function(obj) {
13381339
obj$design$F # Features are used as predictors (y in training function)
13391340
}
13401341

1342+
#' @rdname y_train-methods
13411343
#' @export
13421344
y_train.feature_rsa_design <- function(obj) {
13431345
obj$F # Features are used as predictors

R/mvpa_model.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,12 @@ has_test_set.model_spec <- function(obj) {
174174

175175

176176

177+
#' @rdname y_train-methods
177178
#' @export
178179
y_train.mvpa_model <- function(obj) y_train(obj$design)
179180

180181

182+
#' @rdname y_test-methods
181183
#' @export
182184
y_test.mvpa_model <- function(obj) y_test(obj$design)
183185

0 commit comments

Comments
 (0)