From c5d2a36774ddfe0bff3945614212ea13aec71e02 Mon Sep 17 00:00:00 2001
From: dj44vuri <julian.sagebiel@idiv.de>
Date: Mon, 18 Dec 2023 22:33:02 +0100
Subject: [PATCH] initial commit, only one function

---
 .Rbuildignore     |  3 +++
 .Rhistory         | 23 +++++++++++++++++++++++
 .gitignore        |  1 +
 DCEsim.Rproj      | 22 ++++++++++++++++++++++
 DESCRIPTION       | 19 +++++++++++++++++++
 LICENSE           |  2 ++
 LICENSE.md        | 21 +++++++++++++++++++++
 NAMESPACE         |  3 +++
 R/readdesign.R    | 30 ++++++++++++++++++++++++++++++
 man/readdesign.Rd | 23 +++++++++++++++++++++++
 tests/testthat.R  | 12 ++++++++++++
 11 files changed, 159 insertions(+)
 create mode 100644 .Rbuildignore
 create mode 100644 .Rhistory
 create mode 100644 .gitignore
 create mode 100644 DCEsim.Rproj
 create mode 100644 DESCRIPTION
 create mode 100644 LICENSE
 create mode 100644 LICENSE.md
 create mode 100644 NAMESPACE
 create mode 100644 R/readdesign.R
 create mode 100644 man/readdesign.Rd
 create mode 100644 tests/testthat.R

diff --git a/.Rbuildignore b/.Rbuildignore
new file mode 100644
index 0000000..b49d6fd
--- /dev/null
+++ b/.Rbuildignore
@@ -0,0 +1,3 @@
+^DCEsim\.Rproj$
+^\.Rproj\.user$
+^LICENSE\.md$
diff --git a/.Rhistory b/.Rhistory
new file mode 100644
index 0000000..3219d48
--- /dev/null
+++ b/.Rhistory
@@ -0,0 +1,23 @@
+options(prompt = prompt::prompt_git() )
+install.packages("prompt")
+options(prompt = prompt::prompt_git() )
+usethis::edit_r_profile()
+options(prompt = prompt::prompt_git() )
+options(prompt = "hello" )
+asdf
+options(prompt = prompt::prompt_git() )
+fasjh
+prompt::prompt_git()
+git_branch()
+prompt::prompt_git(git_branch())
+prompt::git_branch()
+usethis::edit_r_profile()
+options(prompt = prompt::git_branch() )
+options(prompt = paste0(prompt::git_branch(), "> ") )
+options(prompt = paste0(prompt::git_branch(), " > ") )
+if (interactive()) prompt::set_prompt(prompt::prompt_git))
+if (interactive()) prompt::set_prompt(prompt::prompt_git)
+if (interactive()) prompt::set_prompt(prompt::prompt_git)
+devtools::check()
+devtools::load_all
+devtools::load_all()
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..cd67eac
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+.Rproj.user
diff --git a/DCEsim.Rproj b/DCEsim.Rproj
new file mode 100644
index 0000000..69fafd4
--- /dev/null
+++ b/DCEsim.Rproj
@@ -0,0 +1,22 @@
+Version: 1.0
+
+RestoreWorkspace: No
+SaveWorkspace: No
+AlwaysSaveHistory: Default
+
+EnableCodeIndexing: Yes
+UseSpacesForTab: Yes
+NumSpacesForTab: 2
+Encoding: UTF-8
+
+RnwWeave: Sweave
+LaTeX: pdfLaTeX
+
+AutoAppendNewline: Yes
+StripTrailingWhitespace: Yes
+LineEndingConversion: Posix
+
+BuildType: Package
+PackageUseDevtools: Yes
+PackageInstallArgs: --no-multiarch --with-keep.source
+PackageRoxygenize: rd,collate,namespace
diff --git a/DESCRIPTION b/DESCRIPTION
new file mode 100644
index 0000000..268a44c
--- /dev/null
+++ b/DESCRIPTION
@@ -0,0 +1,19 @@
+Package: simulateDCE
+Title: Simulate data for discrete choice experiments 
+Version: 0.0.0.9000
+Authors@R: 
+    person("Julian", "Sagebiel", , "julian.sagebiel@idiv.de", role = c("aut", "cre"),
+           comment = c(ORCID = "YOUR-ORCID-ID"))
+Description: A package that supports simulating choice experiment data for given designs. It helps to quickly test different designs against each other.
+License: MIT + file LICENSE
+Encoding: UTF-8
+Roxygen: list(markdown = TRUE)
+RoxygenNote: 7.2.2
+Imports: 
+    dplyr,
+    readr,
+    stringr,
+    tidyr
+Suggests: 
+    testthat (>= 3.0.0)
+Config/testthat/edition: 3
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..d1a8a08
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,2 @@
+YEAR: 2023
+COPYRIGHT HOLDER: simulateDCE authors
diff --git a/LICENSE.md b/LICENSE.md
new file mode 100644
index 0000000..5d934d1
--- /dev/null
+++ b/LICENSE.md
@@ -0,0 +1,21 @@
+# MIT License
+
+Copyright (c) 2023 simulateDCE authors
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/NAMESPACE b/NAMESPACE
new file mode 100644
index 0000000..d7d3adc
--- /dev/null
+++ b/NAMESPACE
@@ -0,0 +1,3 @@
+# Generated by roxygen2: do not edit by hand
+
+export(readdesign)
diff --git a/R/readdesign.R b/R/readdesign.R
new file mode 100644
index 0000000..b0f58bc
--- /dev/null
+++ b/R/readdesign.R
@@ -0,0 +1,30 @@
+
+
+
+
+#'  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
+#'
+#' @return a dataframe
+#' @export
+#'
+#' @examples \dontrun{readdesign("Projects/test/Designs/firstdesign.ngd", "ngene")}
+#'
+readdesign <- function(design = designfile, designtype = destype) {
+  design <- switch(designtype,
+    "ngene" = readr::read_delim(design,
+      delim = "\t",
+      escape_double = FALSE,
+      trim_ws = TRUE,
+      col_select = c(-Design, -tidyr::starts_with("...")),
+      name_repair = "universal", show_col_types = FALSE
+    ) |>
+      dplyr::filter(!is.na(Choice.situation)),
+    "spdesign" = as.data.frame(readRDS(design)) |>
+      dplyr::mutate(Choice.situation = 1:dplyr::n()) |>
+      dplyr::rename_with(~ stringr::str_replace(., pattern = "_", "\\."), everything()),
+    stop("Invalid value for design. Please provide either 'ngene' or 'spdesign'.")
+  )
+}
diff --git a/man/readdesign.Rd b/man/readdesign.Rd
new file mode 100644
index 0000000..441e996
--- /dev/null
+++ b/man/readdesign.Rd
@@ -0,0 +1,23 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/readdesign.R
+\name{readdesign}
+\alias{readdesign}
+\title{Creates a dataframe with the design.}
+\usage{
+readdesign(design = designfile, designtype = destype)
+}
+\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}
+}
+\value{
+a dataframe
+}
+\description{
+Creates a dataframe with the design.
+}
+\examples{
+\dontrun{readdesign("Projects/test/Designs/firstdesign.ngd", "ngene")}
+
+}
diff --git a/tests/testthat.R b/tests/testthat.R
new file mode 100644
index 0000000..54b8562
--- /dev/null
+++ b/tests/testthat.R
@@ -0,0 +1,12 @@
+# This file is part of the standard setup for testthat.
+# It is recommended that you do not modify it.
+#
+# Where should you do additional test configuration?
+# Learn more about the roles of various files in:
+# * https://r-pkgs.org/tests.html
+# * https://testthat.r-lib.org/reference/test_package.html#special-files
+
+library(testthat)
+library(simulateDCE)
+
+test_check("simulateDCE")
-- 
GitLab