From 434fde8b2f28b8fc73deb9c46871454c9fe10bc0 Mon Sep 17 00:00:00 2001
From: Julian Sagebiel <julian.sagebiel@idiv.de>
Date: Tue, 21 May 2024 19:46:43 +0200
Subject: [PATCH] small changes and getting rid of windows lineend

---
 .gitignore                  |  1 +
 DESCRIPTION                 | 10 ++++++++--
 R/createSets.R              | 27 +++++++++++++++++++++++++++
 R/hello.R                   | 18 ------------------
 R/quicktexregapollo.R       | 15 +++++++++++++--
 man/hello.Rd                | 24 ++++++++++++------------
 vignettes/.gitignore        |  2 ++
 vignettes/vignette_name.Rmd | 19 +++++++++++++++++++
 8 files changed, 82 insertions(+), 34 deletions(-)
 delete mode 100644 R/hello.R
 create mode 100644 vignettes/.gitignore
 create mode 100644 vignettes/vignette_name.Rmd

diff --git a/.gitignore b/.gitignore
index f4f606b..ce8cc48 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,4 @@
 .RData
 .Ruserdata
 *.Rproj
+inst/doc
diff --git a/DESCRIPTION b/DESCRIPTION
index 930966a..12876f2 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -3,8 +3,14 @@ Type: Package
 Title: Various tools to work with choice experiment data in R
 Version: 0.1.0
 Author: Julian Sagebiel
-Maintainer: Julian Sagebiel <yourself@somewhere.net>
+Maintainer: Julian Sagebiel <julian.sagebiel@idiv.de>
 Description: Most functions are made for use with apollo.
-License: What license is it under?
+License: MIT
 Encoding: UTF-8
 LazyData: true
+Suggests: 
+    knitr,
+    rmarkdown
+VignetteBuilder: knitr
+Imports: 
+    texreg
diff --git a/R/createSets.R b/R/createSets.R
index 49731a8..d46103c 100644
--- a/R/createSets.R
+++ b/R/createSets.R
@@ -1,3 +1,30 @@
+#' Create sets from given data
+#'
+#' This function creates sets based on given attributes and choice columns.
+#' It groups data by unique rows, calculates counts, and pivots the data for a
+#' comprehensive overview.
+#'
+#' @param .data A data frame or tibble containing the data.
+#' @param choice A string specifying the choice column.
+#' @param attributes A selection condition for attribute columns (tidyselect compatible).
+#' @param uniquerow A string specifying the unique row identifier column.
+#' @param prefix A string specifying the prefix for renaming (default is "a").
+#' @param delimiter A string specifying the delimiter for renaming (default is "_").
+#'
+#' @return A list of tibbles representing the sets.
+#'
+#' @export
+#'
+#' @examples
+#' # Given a package dataset 'sample_data':
+#' createSets(sample_data, choice = "choice_col", attributes = starts_with("attr"), uniquerow = "id")
+
+
+
+
+
+
+
 createSets <- function(.data, choice, attributes , uniquerow, prefix="a") {
   require("dplyr")
   require("tidyr")
diff --git a/R/hello.R b/R/hello.R
deleted file mode 100644
index a793395..0000000
--- a/R/hello.R
+++ /dev/null
@@ -1,18 +0,0 @@
-# Hello, world!
-#
-# This is an example function named 'hello' 
-# which prints 'Hello, world!'.
-#
-# You can learn more about package authoring with RStudio at:
-#
-#   http://r-pkgs.had.co.nz/
-#
-# Some useful keyboard shortcuts for package authoring:
-#
-#   Install Package:           'Ctrl + Shift + B'
-#   Check Package:             'Ctrl + Shift + E'
-#   Test Package:              'Ctrl + Shift + T'
-
-hello <- function() {
-  print("Hello, world!")
-}
diff --git a/R/quicktexregapollo.R b/R/quicktexregapollo.R
index 9c1cc1b..556cd4d 100644
--- a/R/quicktexregapollo.R
+++ b/R/quicktexregapollo.R
@@ -1,7 +1,16 @@
 # This function lets us create output tables with texreg with objects from Apollo
 
 
-quicktexregapollo <- function(model =model, wtpest=NULL) {
+#' Make your apollo object readable with texreg
+#'
+#' @param model the name of the apollo model object
+#' @param wtpest if you want to display wtp instead of beta coefficients provide a dataframe with the wtp values and standard errors
+#'
+#' @return a list opject for texreg
+#' @export
+#'
+#' @examples
+quicktexregapollo <- function(model = model, wtpest = NULL, se="rob") {
 
   modelOutput_settings = list(printPVal=T)
 
@@ -13,9 +22,11 @@ quicktexregapollo <- function(model =model, wtpest=NULL) {
   }
 
 
+
+
   coefnames <- gsub(pattern = "_[a-z]$", "" ,rownames(estimated))
 
-  texout <- createTexreg(coef.names = coefnames , coef = estimated[["estimate"]] , se = estimated[["rob_s_e"]] , pvalues = estimated$p_1_sided_2,
+  texout <- texreg::createTexreg(coef.names = coefnames , coef = estimated[["estimate"]] , se = estimated[["rob_s_e"]] , pvalues = estimated$p_1_sided_2,
                          gof.names = c("No Observations" , "No Respondents" , "Log Likelihood (Null)" , "Log Likelihood (Converged)") ,
                          gof = c(model[["nObsTot"]] , model[["nIndivs"]], model[["LL0"]][[1]] , model[["LLout"]][[1]] ) ,
                          gof.decimal = c(FALSE,FALSE,TRUE,TRUE)
diff --git a/man/hello.Rd b/man/hello.Rd
index 0fa7c4b..ead5524 100644
--- a/man/hello.Rd
+++ b/man/hello.Rd
@@ -1,12 +1,12 @@
-\name{hello}
-\alias{hello}
-\title{Hello, World!}
-\usage{
-hello()
-}
-\description{
-Prints 'Hello, world!'.
-}
-\examples{
-hello()
-}
+\name{hello}
+\alias{hello}
+\title{Hello, World!}
+\usage{
+hello()
+}
+\description{
+Prints 'Hello, world!'.
+}
+\examples{
+hello()
+}
diff --git a/vignettes/.gitignore b/vignettes/.gitignore
new file mode 100644
index 0000000..097b241
--- /dev/null
+++ b/vignettes/.gitignore
@@ -0,0 +1,2 @@
+*.html
+*.R
diff --git a/vignettes/vignette_name.Rmd b/vignettes/vignette_name.Rmd
new file mode 100644
index 0000000..271af86
--- /dev/null
+++ b/vignettes/vignette_name.Rmd
@@ -0,0 +1,19 @@
+---
+title: "vignette_name"
+output: rmarkdown::html_vignette
+vignette: >
+  %\VignetteIndexEntry{vignette_name}
+  %\VignetteEngine{knitr::rmarkdown}
+  %\VignetteEncoding{UTF-8}
+---
+
+```{r, include = FALSE}
+knitr::opts_chunk$set(
+  collapse = TRUE,
+  comment = "#>"
+)
+```
+
+```{r setup}
+library(choiceTools)
+```
-- 
GitLab