diff --git a/.gitignore b/.gitignore index f4f606b08247414e98fdb3ffca335cef87e17e7d..ce8cc485e256ed71108b48ec45dedb921b53b2d3 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ .RData .Ruserdata *.Rproj +inst/doc diff --git a/DESCRIPTION b/DESCRIPTION index 930966af9e7b8413fd8b5107b1966034922903d6..12876f2cfeb9554eb7a9ea41a935747c9295dec9 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 49731a89041451a2dd9674891ac4a866492a4ffa..d46103c47c9fa2a48d45cf6bb966d5282f3cb8bd 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 a793395cc63acb686e00c952d53785207798a627..0000000000000000000000000000000000000000 --- 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 9c1cc1bb50b009d50e1753cb79425064258d0dd5..556cd4db7024e2e640d67ee59045351afcd9239f 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 0fa7c4b8817591c2dff2b3997d2566320ac6d9fc..ead5524b9caae4e4c4f181deb6b2aa7b162a2bb7 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 0000000000000000000000000000000000000000..097b241637da023174b0f2e3715bd0291d9ded37 --- /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 0000000000000000000000000000000000000000..271af865b4833b7489e6269a7ed71d53dc6414dd --- /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) +```