Connect with me on Open Science Framework | Contact me via LinkedIn
Depending on your machine it might be necessary to use right-click -> open in new browser window.
R analysis script presenting the examples studied in Chapter 7 of the Sensory Marketing lecture
If this exercise grabs your attention, please check-out our study programs at the Chemnitz University of Technology by clicking on the logo (Germany):
Beware: R is a context-sensitive language. Thus, ‘data’ will be interpreted not in the same way as ‘Data’ will.
In R most functionality is provided by additional packages.
Most of the packages are well-documented, See: https://cran.r-project.org/
The code chunk below first evaluates if the package pacman is already installed to your machine. If yes, the corresponding package will be loaded. If not, R will install the package.
Alternatively, you can do this manually first by executing install.packages(“pacman”) and then library(pacman).
The second line then loads the package pacman
The third line uses the function p_load() from the pacman package to install (if necessary) and load all packages that we provide as arguments (e.g., osfr, which provides functions for interfacing with the open science framework from R).
if(!"pacman" %in% rownames(installed.packages())) install.packages("pacman")
library(pacman)
pacman::p_load(tidyverse, dplyr, tidyselect, sensR, SensoMineR)
Here is the R session info which gives you information on my machine, all loaded packages and their version:
sessionInfo()
## R version 4.1.2 (2021-11-01)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 10 x64 (build 19044)
##
## Matrix products: default
##
## locale:
## [1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252
## [3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C
## [5] LC_TIME=German_Germany.1252
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] SensoMineR_1.26 FactoMineR_2.4 sensR_1.5-2 tidyselect_1.1.1
## [5] forcats_0.5.1 stringr_1.4.0 dplyr_1.0.6 purrr_0.3.4
## [9] readr_2.1.1 tidyr_1.1.4 tibble_3.1.2 ggplot2_3.3.5
## [13] tidyverse_1.3.1 pacman_0.5.1
##
## loaded via a namespace (and not attached):
## [1] httr_1.4.2 sass_0.4.0 jsonlite_1.7.2
## [4] splines_4.1.2 gtools_3.9.2 modelr_0.1.8
## [7] bslib_0.3.1 assertthat_0.2.1 cellranger_1.1.0
## [10] yaml_2.2.1 ggrepel_0.9.1 numDeriv_2016.8-1.1
## [13] pillar_1.6.4 backports_1.4.1 lattice_0.20-45
## [16] glue_1.4.2 digest_0.6.29 rvest_1.0.2
## [19] colorspace_2.0-1 sandwich_3.0-1 plyr_1.8.6
## [22] htmltools_0.5.2 Matrix_1.3-4 pkgconfig_2.0.3
## [25] broom_0.7.10 haven_2.4.3 mvtnorm_1.1-3
## [28] scales_1.1.1 tzdb_0.2.0 generics_0.1.1
## [31] DT_0.20 ellipsis_0.3.2 TH.data_1.1-0
## [34] withr_2.4.3 cli_3.1.0 survival_3.2-13
## [37] magrittr_2.0.1 crayon_1.4.2 readxl_1.3.1
## [40] evaluate_0.14 fs_1.5.2 fansi_0.4.2
## [43] MASS_7.3-54 xml2_1.3.3 tools_4.1.2
## [46] hms_1.1.1 lifecycle_1.0.1 multcomp_1.4-17
## [49] munsell_0.5.0 reprex_2.0.1 cluster_2.1.2
## [52] flashClust_1.01-2 compiler_4.1.2 jquerylib_0.1.4
## [55] rlang_0.4.11 grid_4.1.2 rstudioapi_0.13
## [58] htmlwidgets_1.5.4 leaps_3.1 rmarkdown_2.11
## [61] gtable_0.3.0 codetools_0.2-18 DBI_1.1.1
## [64] AlgDesign_1.2.0 reshape2_1.4.4 R6_2.5.1
## [67] zoo_1.8-9 lubridate_1.8.0 knitr_1.37
## [70] fastmap_1.1.0 utf8_1.2.1 KernSmooth_2.23-20
## [73] stringi_1.7.6 Rcpp_1.0.7 vctrs_0.3.8
## [76] scatterplot3d_0.3-41 dbplyr_2.1.1 xfun_0.29
triangle_test <- discrim(
correct= 43,
total= 100,
conf.level = 0.95,
method = "triangle",
statistic = "score",
test = "difference")
print(triangle_test)
##
## Estimates for the triangle discrimination protocol with 43 correct
## answers in 100 trials. One-sided p-value and 95 % two-sided confidence
## intervals are based on the Pearson and score statistics.
##
## Estimate Std. Error Lower Upper
## pc 0.430 0.04951 0.3333 0.5328
## pd 0.145 0.07426 0.0000 0.2992
## d-prime 1.075 0.30276 0.0000 1.6355
##
## Result of difference test:
## Pearson X-square statistic = 4.205, df = 1, p-value: 0.02015
## Alternative hypothesis: d-prime is greater than 0
#plot(triangle_test)