diff --git a/R/readdesign.R b/R/readdesign.R index fb67522dfc23f948ee52320dc6c3b9d85928cf36..60773518f3a13facf7b8d3df973c2a445489d2e2 100644 --- a/R/readdesign.R +++ b/R/readdesign.R @@ -5,7 +5,7 @@ #' Creates a dataframe with the design. #' #' @param design The path to a design file -#' @param designtype Is it a design created with ngene or with spdesign. Ngene desings should be stored as the standard .ngd output. spdesign should be the spdesign object design$design +#' @param designtype Is it a design created with ngene or with spdesign. Ngene desings should be stored as the standard .ngd output. spdesign should be the spdesign object stored as an RDS file. If designtype is not specified, I try to guess what it is. This is especially helpful if you want to carry out a simulation for both spdesign designs and ngene designs at the same time. #' #' @return a dataframe #' @export @@ -27,14 +27,14 @@ readdesign <- function(design = designfile, designtype = NULL) { # Check if the string ends with ".ngd" - if (grepl("\\.ngd$", designfile)) { + if (grepl("\\.ngd$", design)) { # Code to execute if condition is true designtype = "ngene" - print("I guessed it is an ngene file") + message("I guessed it is an ngene file") } else { # Code to execute if condition is false designtype = "spdesign" - print("I assume it is a spdesign") + message("I assume it is a spdesign") } } @@ -66,7 +66,7 @@ readdesign <- function(design = designfile, designtype = NULL) { } , - stop("Invalid value for design. Please provide either 'ngene' or 'spdesign'.") + stop("Invalid value for design. Please provide either 'ngene' or 'spdesign', or do not use the argument 'designtype'.") ) } diff --git a/man/readdesign.Rd b/man/readdesign.Rd index b74ed46354627eecd771e72cd4a7d30282d846f0..72011ee146d2df2389a101d24e0427090c0ad0f8 100644 --- a/man/readdesign.Rd +++ b/man/readdesign.Rd @@ -4,12 +4,12 @@ \alias{readdesign} \title{Creates a dataframe with the design.} \usage{ -readdesign(design = designfile, designtype = destype) +readdesign(design = designfile, designtype = NULL) } \arguments{ \item{design}{The path to a design file} -\item{designtype}{Is it a design created with ngene or with spdesign. Ngene desings should be stored as the standard .ngd output. spdesign should be the spdesign object design$design} +\item{designtype}{Is it a design created with ngene or with spdesign. Ngene desings should be stored as the standard .ngd output. spdesign should be the spdesign object stored as an RDS file. If designtype is not specified, I try to guess what it is. This is especially helpful if you want to carry out a simulation for both spdesign designs and ngene designs at the same time.} } \value{ a dataframe diff --git a/tests/testthat/test-readdesign.R b/tests/testthat/test-readdesign.R index 97a3658fc86d52b2d2e5ee63841834e67e80dd8e..dcb699e5a537c583ef8019d9f26fe83becac7ff6 100644 --- a/tests/testthat/test-readdesign.R +++ b/tests/testthat/test-readdesign.R @@ -17,8 +17,8 @@ test_that("all is correct", { # test if autodetect ngd design -test_that("all is correct", { - expect_no_error(readdesign(design = design_path)) +test_that("expect message of guess", { + expect_message(readdesign(design = design_path), "I guessed it is an ngene file") }) @@ -32,8 +32,8 @@ test_that("all is correct", { # Same Tests for spdesign, but detect automatically if it is spdesign -test_that("all is correct", { - expect_no_error(readdesign(design = design_path)) +test_that("prints message for guessing", { + expect_message(readdesign(design = design_path), "I assume it is a spdesign") }) diff --git a/vignettes/csa-vignette.Rmd b/vignettes/csa-vignette.Rmd index 2b23f1a0b29aea2e60be7483c4157da58a3cc515..d5ebb3a6df56a06b23b64b6458b7ffab4bae0378 100644 --- a/vignettes/csa-vignette.Rmd +++ b/vignettes/csa-vignette.Rmd @@ -71,7 +71,7 @@ The simulation can be ran using spdesign or NGENE design files which will be con ```{r other} -designpath<- system.file("extdata","CSA" ,package = "simulateDCE") +designpath<- system.file("extdata","CSA", "linear" ,package = "simulateDCE") ## can also be specified using relative path eg. designpath<- "Projects/CSA/Designs/" #notes <- "This design consists of different heuristics. One group did not attend the methan attribute, another group only decided based on the payment"