Skip to content
Snippets Groups Projects
Commit f7abf051 authored by dj44vuri's avatar dj44vuri
Browse files

corrected tests for readdesign, solved small issues with path for csa vignette

parent 42d6ff2d
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#' Creates a dataframe with the design. #' Creates a dataframe with the design.
#' #'
#' @param design The path to a design file #' @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 #' @return a dataframe
#' @export #' @export
...@@ -27,14 +27,14 @@ readdesign <- function(design = designfile, designtype = NULL) { ...@@ -27,14 +27,14 @@ readdesign <- function(design = designfile, designtype = NULL) {
# Check if the string ends with ".ngd" # Check if the string ends with ".ngd"
if (grepl("\\.ngd$", designfile)) { if (grepl("\\.ngd$", design)) {
# Code to execute if condition is true # Code to execute if condition is true
designtype = "ngene" designtype = "ngene"
print("I guessed it is an ngene file") message("I guessed it is an ngene file")
} else { } else {
# Code to execute if condition is false # Code to execute if condition is false
designtype = "spdesign" 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) { ...@@ -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'.")
) )
} }
......
...@@ -4,12 +4,12 @@ ...@@ -4,12 +4,12 @@
\alias{readdesign} \alias{readdesign}
\title{Creates a dataframe with the design.} \title{Creates a dataframe with the design.}
\usage{ \usage{
readdesign(design = designfile, designtype = destype) readdesign(design = designfile, designtype = NULL)
} }
\arguments{ \arguments{
\item{design}{The path to a design file} \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{ \value{
a dataframe a dataframe
......
...@@ -17,8 +17,8 @@ test_that("all is correct", { ...@@ -17,8 +17,8 @@ test_that("all is correct", {
# test if autodetect ngd design # test if autodetect ngd design
test_that("all is correct", { test_that("expect message of guess", {
expect_no_error(readdesign(design = design_path)) expect_message(readdesign(design = design_path), "I guessed it is an ngene file")
}) })
...@@ -32,8 +32,8 @@ test_that("all is correct", { ...@@ -32,8 +32,8 @@ test_that("all is correct", {
# Same Tests for spdesign, but detect automatically if it is spdesign # Same Tests for spdesign, but detect automatically if it is spdesign
test_that("all is correct", { test_that("prints message for guessing", {
expect_no_error(readdesign(design = design_path)) expect_message(readdesign(design = design_path), "I assume it is a spdesign")
}) })
......
...@@ -71,7 +71,7 @@ The simulation can be ran using spdesign or NGENE design files which will be con ...@@ -71,7 +71,7 @@ The simulation can be ran using spdesign or NGENE design files which will be con
```{r other} ```{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/" ## 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" #notes <- "This design consists of different heuristics. One group did not attend the methan attribute, another group only decided based on the payment"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment