Data Science for Sensory and Consumer Scientists is a comprehensive textbook that provides a practical guide to using data science in the field of sensory and consumer science through real-world applications. It covers key topics including data manipulation, preparation, visualization, and analysis, as well as automated reporting, machine learning, text analysis, and dashboard creation. Written by leading experts in the field, this book is an essential resource for anyone looking to master the tools and techniques of data science and apply them to the study of consumer behavior and sensory-led product development. Whether you are a seasoned professional or a student just starting out, this book is the ideal guide to using data science to drive insights and inform decision-making in the sensory and consumer sciences. Key Features: Elucidation of data scientific workflow. Introduction to reproducible research. In-depth coverage of data-scientific topics germane to sensory and consumer science. Examples based in industrial practice used throughout the book 1. Bienvenue!.........................................................................................................................1 1.1 WhyDataScienceforSensoryandConsumerScience?..................1 1.1.1 CorePrinciplesinSensoryandConsumerScience.............1 1.1.2 ComputationalSensoryScience...............................................7 2. Getting Started.............................................................................................................9 2.1 IntroductiontoR.......................................................................................9 2.1.1 WhatIsR?....................................................................................9 2.1.2 WhyLearnR(orAnyProgrammingLanguage)?..............9 2.1.3 WhyR?........................................................................................10 2.1.4 WhyRStudio/Posit?................................................................11 2.1.5 InstallingRandRStudio.........................................................12 2.2 GettingStartedwithR..........................................................................12 2.2.1 Conventions.................................................................................12 2.2.2 InstallandLoadPackages.......................................................13 2.2.3 FirstAnalysisinR....................................................................15 2.2.4 RScripts......................................................................................16 2.2.5 CreateaLocalProject.............................................................17 2.3 FurtherTipsonHowtoReadThisBook?.......................................18 2.3.1 Introduction to {magrittr} and the Notion of Pipes.....19 2.3.2 Tibbles..........................................................................................21 2.3.3 CallingVariables........................................................................26 2.3.4 Printingvs. SavingResults.....................................................27 2.3.5 RunningCodeandHandlingErrors.....................................29 2.4 VersionControl/GitandGitHub........................................................30 2.4.1 Git..................................................................................................30 2.4.2 GitHub..........................................................................................31 3. Why Data Science?..................................................................................................33 3.1 HistoryandDefinition............................................................................33 3.2 BenefitsofDataScience.........................................................................35 3.2.1 ReproducibleResearch.............................................................35 3.2.2 StandardizedReporting...........................................................35 3.3 DataScientificWorkflow........................................................................36 3.3.1 DataCollection..........................................................................36 3.3.2 DataPreparation.......................................................................37 vii viii Contents 3.3.3 DataAnalysis.............................................................................38 3.3.4 ValueDelivery............................................................................40 3.4 HowtoLearnDataScience...................................................................41 3.5 Cautions:Don’tDoThatEverybodyDoes......................................41 4. Data Manipulation...................................................................................................43 4.1 WhyManipulatingData?......................................................................43 4.2 TidyingData.............................................................................................45 4.2.1 SimpleManipulations...............................................................45 4.2.2 ReshapingData..........................................................................59 4.2.3 TransformationThatAlterstheData.................................63 4.2.4 CombiningDatafromDifferentSources.............................67 5. Data Visualization....................................................................................................73 5.1 Introduction...............................................................................................73 5.2 DesignPrinciples......................................................................................74 5.3 TableMaking............................................................................................76 5.3.1 Introduction to {flextable}...................................................76 5.3.2 Introdution to {gt}...................................................................80 5.4 ChartMaking............................................................................................85 5.4.1 Philosophy of {ggplot2}.........................................................85 5.4.2 Getting Started with {ggplot2}...........................................85 5.4.3 CommonCharts.........................................................................97 5.4.4 Miscealleneous..........................................................................100 5.4.5 Few Additional Tips and Tricks..........................................107 6. Automated Reporting.........................................................................................113 6.1 WhatandWhyAutomatedReporting?..........................................113 6.2 IntegratingReportswithinAnalysisScripts..................................114 6.2.1 Excel............................................................................................115 6.2.2 PowerPoint................................................................................120 6.2.3 Word ...........................................................................................130 6.2.4 NotesonApplyingCorporateBranding ...........................132 6.3 Integrating Analyses Scripts Within Your Reporting Tool........133 6.3.1 What Is {rmarkdown}............................................................133 6.3.2 Starting with {rmarkdown}...................................................134 6.3.3 {rmarkdown} through a Simple Example.........................134 6.3.4 Creating a Document Using {knitr}................................136 6.3.5 Example of Applications........................................................136 6.4 ToGoFurther......................................................................................137 Contents ix 7. Example Project: The Biscuit Study.......................................................139 7.1 ObjectiveoftheTest ............................................................................139 7.2 Products...................................................................................................140 7.3 SensoryDescriptiveAnalysis..............................................................140 7.4 Consumer Test........................................................................................141 7.4.1 Participants...............................................................................141 7.4.2 Test Design................................................................................141 7.4.3 Evaluation..................................................................................143 8. Data Collection.........................................................................................................145 8.1 DesignsofSensoryExperiments........................................................145 8.1.1 General Approach....................................................................145 8.1.2 Crossover Designs....................................................................147 8.1.3 BalancedIncompleteBlockDesigns(BIBD)...................150 8.1.4 IncompleteDesignsandSensoryInformedDesignsfor Hedonic Tests............................................................................151 8.2 Product-related Designs.......................................................................155 8.2.1 Factorial Designs......................................................................155 8.2.2 Mixture Designs.......................................................................155 8.2.3 ScreeningDesigns....................................................................159 8.2.4 SensoryInformedDesignsforProductDevelopment....160 8.3 Execute.....................................................................................................161 8.4 Import.......................................................................................................164 8.4.1 ImportingStructuredExcelFile.........................................165 8.4.2 ImportingUnstructuredExcelFile ....................................166 8.4.3 Importing Data Stored in Multiple Sheets.......................168 9. Data Preparation....................................................................................................171 9.1 Introduction.............................................................................................171 9.2 Inspect.......................................................................................................172 9.2.1 Data Inspection........................................................................172 9.2.2 Missing Data.............................................................................175 9.2.3 DesignInspection....................................................................185 9.3 Clean.........................................................................................................188 9.3.1 Handling Data Type...............................................................188 9.3.2 Converting between Types....................................................196 10. Data Analysis.............................................................................................................199 10.1 Sensory Data...........................................................................................199 10.2 Demographic and Questionnaire Data.............................................207 10.2.1 DemographicData:FrequencyandProportion..............207 10.2.2 EatingBehaviorTraits:TFEQData.................................211 10.3 Consumer Data.......................................................................................217 x Contents 10.4 Combining Sensory and Consumer Data.........................................222 10.4.1 Internal Preference Mapping................................................222 10.4.2 ConsumersClustering ............................................................225 10.4.3 Drivers of Liking......................................................................230 10.4.4 External Preference Mapping...............................................235 11. Value Delivery...........................................................................................................239 11.1 HowtoCommunicate?.........................................................................239 11.2 Exploratory, Explanatory, and Predictive Analysis......................241 11.3 Audience Awareness..............................................................................242 11.3.1 TechnicalAudience.................................................................244 11.3.2 Management..............................................................................244 11.3.3 GeneralInterest.......................................................................244 11.4 MethodstoCommunicate...................................................................249 11.4.1 ConsidertheMechanism .......................................................249 11.4.2 Pick the Correct Format........................................................250 11.5 Storytelling..............................................................................................251 11.5.1 TheBeginning(Context)......................................................252 11.5.2 The Middle (Action and Impact)........................................253 11.5.3 The End (Conclusion)............................................................253 11.6 Reformulate.............................................................................................254 12. Machine Learning...................................................................................................255 12.1 Introduction.............................................................................................255 12.2 Introduction of the Data......................................................................257 12.3 Machine Learning Methods.................................................................257 12.4 Unsupervised Machine Learning........................................................258 12.4.1 DimensionalityReduction.....................................................259 12.4.2 Clustering..................................................................................261 12.5 Supervised Learning..............................................................................264 12.5.1 Workflow....................................................................................265 12.5.2 Regression..................................................................................265 12.5.3 OtherCommonSupervisedMLAlgorithms....................267 12.6 Practical Guide to Supervised Machine Learning.........................268 12.6.1 Introduction to the {tidymodels} Framework...............268 12.6.2 SamplingtheData..................................................................269 12.6.3 Cross-Validation.......................................................................269 12.6.4 Data Preprocessing {recipes}............................................270 12.6.5 ModelDefinition......................................................................271 12.6.6 SettheWholeProcessintoaWorkflow............................271 12.6.7 Tuning the Parameters...........................................................272 12.6.8 Model Training.........................................................................272 12.6.9 ModelEvaluation....................................................................273 Contents xi 13. Text Analysis..............................................................................................................279 13.1 Introduction to Natural Language Processing...............................279 13.2 Application of Text Analysis in Sensory and Consumer Science..................................................................................280 13.2.1 Text Analysis as Way to Describe Products....................280 13.2.2 Objectives of Text Analysis..................................................281 13.2.3 ClassicalTextAnalysisWorkflow.......................................282 13.2.4 Warnings....................................................................................282 13.3 Illustration Involving Sorting Task Data.........................................283 13.3.1 DataPreprocessing.................................................................283 13.3.2 Introduction to Working with Strings ({stringr}).......284 13.3.3 Tokenization..............................................................................284 13.3.4 SimpleTransformations.........................................................285 13.3.5 SplittingFurthertheTokens................................................286 13.3.6 Stopwords..................................................................................287 13.3.7 Stemming and Lemmatization.............................................289 13.4 TextAnalysis..........................................................................................292 13.4.1 RawFrequenciesandVisualization....................................293 13.4.2 Bigramsandn-grams .............................................................298 13.4.3 Word Embedding.....................................................................299 13.4.4 Sentiment Analysis..................................................................300 13.5 ToGoFurther......................................................................................300 14. Dashboards...................................................................................................................301 14.1 Objectives ................................................................................................301 14.2 Introduction to Shiny through an Example....................................302 14.2.1 What Is a Shiny Application?..............................................302 14.2.2 Starting with Shiny.................................................................302 14.2.3 Illustration.................................................................................302 14.2.4 DeployingtheApplication....................................................308 14.3 ToGoFurther......................................................................................308 14.3.1 PersonalizingandTuningYourApplication....................309 14.3.2 Upgrading Tables.....................................................................309 14.3.3 BuildingDashboard................................................................310 14.3.4 Interactive Graphics................................................................311 14.3.5 InteractiveDocuments...........................................................311 14.3.6 Documentation and Books....................................................312 15. Conclusion and Next Steps.............................................................................313 15.1 Other Recommended Resources.........................................................313 15.2 Useful R Packages..................................................................................314 Bibliography..............................................................................................................................317 Index ............................................................................................................................................327