CRAN Recipes : DPLYR, Stringr, Lubridate, and RegEx in R
معرفی کتاب «CRAN Recipes : DPLYR, Stringr, Lubridate, and RegEx in R» نوشتهٔ William Yarberry، منتشرشده توسط نشر Apress : Imprint: Apress در سال 2021. این کتاب در فرمت pdf، زبان انگلیسی ارائه شده است.
Want to use the power of R sooner rather than later? Don’t have time to plow through wordy texts and online manuals? Use this book for quick, simple code to get your projects up and running. It includes code and examples applicable to many disciplines. Written in everyday language with a minimum of complexity, each chapter provides the building blocks you need to fit R’s astounding capabilities to your analytics, reporting, and visualization needs. __CRAN Recipes__ recognizes how needless jargon and complexity get in your way. Busy professionals need simple examples and intuitive descriptions; side trips and meandering philosophical discussions are left for other books. Here R scripts are condensed, to the extent possible, to copy-paste-run format. Chapters and examples are structured to purpose rather than particular functions (e.g., “dirty data cleanup” rather than the R package name “janitor”). Everyday language eliminates the need to know functions/packages in advance. **What You Will Learn** * Carry out input/output; visualizations; data munging; manipulations at the group level; and quick data exploration * Handle forecasting (multivariate, time series, logistic regression, Facebook’s Prophet, and others) * Use text analytics; sampling; financial analysis; and advanced pattern matching (regex) * Manipulate data using DPLYR: filter, sort, summarize, add new fields to datasets, and apply powerful IF functions * Create combinations or subsets of files using joins * Write efficient code using pipes to eliminate intermediate steps (MAGRITTR) * Work with string/character manipulation of all types (STRINGR) * Discover counts, patterns, and how to locate whole words * Do wild-card matching, extraction, and invert-match * Work with dates using LUBRIDATE * Fix dirty data; attractive formatting; bad habits to avoid **Who This Book Is For** Programmers/data scientists with at least some prior exposure to R. Table of Contents About the Author About the Technical Reviewer Acknowledgments Introduction Chapter 1: DPLYR 1.1 Filter Commands 1.1.1 Single-Condition Filter 1.1.2 Multiple-Condition Filter 1.1.3 OR Logic for Filtering 1.1.4 Filter by Minimums, Maximums, and Other Numeric Criteria 1.1.5 Filter Out Missing Values (NAs) for a Specific Column 1.1.6 Filter Rows with NAs Anywhere in the Dataset 1.1.7 Filter by %in% 1.1.8 Filter for Ozone > 29 and Include Only Three Columns 1.1.9 Filter by Total Frequency of a Value Across All Rows 1.1.10 Filter by Column Name Using “starts with” 1.1.11 Filter Rows: Columns Meet Criteria (filter_at) 1.2 Arrange (Sort) 1.2.1 Ascending 1.2.2 Descending 1.3 Rename 1.4 Mutate 1.4.1 mutate_all to Add New Fields All at Once 1.4.2 mutate_at to Add Fields 1.4.3 mutate_if 1.4.4 String Detect and True/False Duplicate Indicator 1.4.5 Drop Variables Using NULL 1.4.6 Preferred coding sequence 1.4.7 Transmute: Keep Only Variables Created 1.4.8 Use Across to Apply a Function over Multiple Columns 1.4.9 Conditional Mutating Using case_when 1.5 Select to Choose Variables/Columns 1.5.1 Delete a Column 1.5.2 Delete Columns by Name Using starts_with or ends_with 1.5.3 Rearrange Column Order 1.5.4 select_all to Apply a Function to All Columns 1.5.5 Select Columns Using the Pull Function 1.5.6 Select Rows: Any Variable Meets Some Condition 1.5.7 Select Columns: Omit If Column Name Contains Specific Characters 1.5.8 Select Using Wildcard Matching 1.6 Joins: Manipulations of Data from Two Sources 1.6.1 Left Join (Most Common) 1.6.2 Inner Join 1.6.3 Anti-join 1.6.4 Full Join 1.6.5 Semi-join 1.6.6 Right Join 1.7 Slice 1.8 Summarise 1.8.1 Summarise Across 1.9 Gathering: Convert Multiple Columns into One 1.10 Spreading: Consolidation of Multiple Rows into One 1.11 Separate: Divide a Single Column into Multiple Columns 1.12 Recap of Handy DPLYR Functions 1.12.1 Number of Observations (n) Used Across Multiple DPLYR Functions 1.12.2 Basic Counts 1.12.3 Nth Functions 1.12.4 Count Distinct Values 1.12.5 na_if 1.12.6 Coalesce to Replace Missing Values 1.13 Ranking Functions 1.13.1 Ranking via Index 1.13.2 Minimum Rank 1.13.3 Dense Rank 1.13.4 Percent Rank 1.13.5 Cumulative Distribution Function 1.14 Sampling 1.15 Miscellaneous DPLYR Functions 1.15.1 add_count for Groupwise Filtering 1.15.2 Rename 1.15.3 case_when Chapter 2: Stringr 2.1 Introduction 2.2 Stringr Functions 2.2.1 Find, Count, and Extract 2.2.2 String Detect 2.2.3 String Count 2.2.4 String Remove 2.2.5 String Replace 2.2.6 String Starts 2.2.7 String Ends 2.2.8 String Subset 2.2.9 String Which 2.2.10 String Extraction Using Regular Expressions 2.2.11 String Extract All 2.2.12 String Glue 2.2.13 String Order (Sorting) 2.3 Get or Modify String Information 2.3.1 Extract/Match All 2.3.2 Case Functions 2.3.3 Geographically Aware (Locale-Aware) Functions 2.3.4 Combine Multiple Strings 2.4 More Complex Matching 2.4.1 What Does Not Match (Invert-Match) 2.5 Convenient Word Wrapping 2.6 Cleanup and Padding 2.6.1 Pad Your String, Not Your Expense Account 2.6.2 Trim Whitespace from a String Using str_trim 2.6.3 Remove All Whitespace from a String 2.6.4 Truncate a String 2.7 Regular Expressions with Stringr 2.7.1 Regular Expression Variations Chapter 3: Lubridate: Date and Time Processing 3.1 Hard-Coding Coffee Time 3.2 Duration Calculations 3.3 Spanning Two Dates Using Interval 3.3.1 Work with Time Zones 3.4 Calculate Duration (Seconds) Between Two Date/Times 3.5 More Interval Calculations 3.6 Interval Overlaps 3.7 Interval Shift 3.8 Alignment 3.9 Periods 3.10 Sequencing 3.11 Distinction Between Period and Duration 3.12 Timespan 3.12.1 Contrast of Intervals and Durations 3.12.2 Coordinated Universal Time Zone (UTC) 3.12.3 as_date vs. as.Date 3.12.4 Create a Date/Time Object via Hard Coding 3.12.5 Revise a Date by Individually Changing Month, Day, Year 3.12.6 Fractional Year 3.12.7 Work Day 3.12.8 Is Daylight Savings Time in Effect? 3.12.9 Guess Formats 3.12.10 Hour Function 3.12.11 Extract Names from Date 3.12.12 Parse Periods with Hour, Minute, and Second Components 3.13 Parse Date-Time: A Lubridate Workhorse 3.14 Date Validation 3.14.1 Calculate Time Difference 3.14.2 Time Zones 3.14.3 Shorthand Methods to Designate Date/Times 3.14.4 Work with Weeks 3.14.5 Test Interval or Date: Is It Within Another Interval? 3.14.6 Miscellaneous Functions: Create a Specified Time Difference 3.14.7 Force a Date/Time to Be in a Different Time Zone 3.14.8 Working with Different Time Zones in the Same Calculations 3.14.9 Eastern Daylight Savings and Other Time Examples 3.14.10 Internationalization 3.14.10.1 Is There Any Good Locale News? 3.14.11 now(), Rollback, and Rounding 3.14.11.1 Right Now 3.14.11.2 Rollback 3.14.11.3 Rounding 3.14.11.4 Automatic Roll over Arithmetic Chapter 4: Regular Expressions: Introduction 4.1 RegEx: A Few Tips to Get Started 4.2 Challenges and Promises of Regular Expressions Chapter 5: Typical Uses 5.1 Test for a Match 5.2 Validation (e.g., Passwords) 5.3 Find All Numbers and Periods in a String 5.4 Change Characters 5.5 Format Strings 5.6 Email 5.7 Example Validations with RegEx 5.7.1 Amex Card Number 5.7.2 Email 5.7.3 IP4 Address 5.7.4 US Social Security Number 5.8 Remove Path Information from a String, Showing Only File Name 5.9 Remove Non-digits 5.10 Extract File Type from a URL 5.10.1 Replace Any String with Same, Adjacent Letters 5.10.2 Find Adjacent Duplicates but Not Repeats of Three or More 5.11 Some Other RegEx Uses Chapter 6: Some Simple Patterns 6.1 Extract Lowest-Level Subdirectory from a File Path 6.2 Find URL in a String of Text 6.3 Find Zip Codes Within a String (e.g., Full Addresses) 6.4 Codes for Regular Expressions Chapter 7: Character Classes 7.1 DOT 7.2 Anchors 7.3 Multiline Specification 7.4 Word Boundaries 7.5 Whitespace 7.6 Extended Regular Expressions 7.7 How to Set Locale Chapter 8: Elements of Regular Expressions 8.1 Meta-characters 8.2 Ranges 8.2.1 Numeric 8.2.2 Alpha 8.3 Case Sensitivity 8.4 Repetition 8.5 Negations: NOT Syntax 8.6 Grouping 8.7 Alternation: OR Syntax 8.7.1 The Alternation Operator (| or \|) 8.8 Quantifiers 8.9 Case Sensitivity 8.10 Partial Match 8.11 The Alternation “|” Meta-character 8.12 Look Ahead and Look Behind 8.12.1 Starter Examples 8.12.2 Structure of Look Ahead/Look Behind 8.12.3 Easy-to-Use and Easy-to-Understand Sets of Characters Chapter 9: The Magnificent Seven 9.1 grep 9.1.1 Pattern Matching and Replacement 9.1.2 Function Structure 9.2 grepl 9.2.1 Whitespace 9.3 sub 9.4 gsub 9.4.1 More gsub Examples 9.5 regexpr 9.6 gregexpr 9.7 regexec Chapter 10: Regular Expressions in Stringr Chapter 11: Unicode 11.1 The World of ASCII, UTF-8, Latin-1, and All the Rest Chapter 12: Tools for Development and Resources 12.1 Utilities 12.1.1 regex101.com 12.1.2 RegExBuddy 12.1.3 Other Utilities 12.1.4 Text Editors with Built-In RegEx Capability 12.1.4.1 Use of RegEx Inside Notepad++ 12.1.5 Regular Expression Capability in Google Sheets 12.1.6 RegEx in RStudio Chapter 13: RegEx Summary Chapter 14: Recipes for Common R Tasks 14.1 Input-Output 14.1.1 Console Input 14.1.2 Read and Write CSV Files 14.1.3 Windows: Copy a File Chapter 15: Data Structures 15.1 Built-In Datasets Chapter 16: Visualization 16.1 Histogram 16.2 Chart Variations 16.2.1 Horizontal Bar Charts (Faceted) 16.2.2 Lollipop 16.2.3 Step Chart 16.2.4 Diverging Bars 16.2.5 Colorful Display of Categorical/Character Frequencies 16.2.6 Donut Chart 16.2.7 Bubble Plot 16.2.8 Scatterplot 16.2.9 Scatterplot with Fitted Loess Curve 16.2.10 Yearly Plot Using Alternative Theme 16.2.11 Plot All Variables in a Dataframe Against All Other Variables 16.2.12 Line Plot Using Two Sources of Data 16.2.13 Correlogram 16.2.14 Word Cloud 16.2.15 ggplot Time Series: Airline Crash Historical Data 16.2.16 Textplot 16.2.17 Dot Plot 16.2.18 Survival Analysis Chapter 17: Simple Prediction Methods 17.1 Prophet: Time Series Modeling 17.2 Holt-Winters Model 17.3 Multivariate Regression Chapter 18: Smorgasbord of Simple Statistical Tests 18.1 Basic Numeric Vector Tests 18.1.1 Coefficient of Variation 18.1.2 Str 18.1.3 Five-Number Tukey Statistics 18.2 Attractive Tabular Output 18.2.1 sjPlot 18.2.2 Formattable 18.3 Distributions 18.3.1 Normal 18.3.2 Binomial 18.3.3 Poisson 18.4 Quick Data Exploration 18.4.1 Convenience Summaries 18.4.11 dfSummary 18.4.12 Skimr 18.4.13 Hmisc 18.4.14 Summary 18.5 Numeric Vectors 18.6 Heatmap of Correlations 18.7 Easy Models 18.7.1 Generalized Linear Model 18.7.2 Prediction Using Simple Linear Regression 18.7.3 Text Mining/Analytics 18.8 Sampling 18.8.1 Sampling with Replacement 18.8.2 Split Sample (Control vs. Treatment) 18.9 Financial Functions Chapter 19: Validation of Data Chapter 20: Shortcuts and Miscellaneous 20.1 RStudio 20.2 Utilities 20.2.1 Remove Read-Only Property from a Windows File 20.2.2 Rename a Windows File 20.3 Debugging R Code Chapter 21: Conclusion Appendix A: Suggested Websites Appendix B: Cheat Sheet for RegEx in R Appendix C: General R Comments by John D. Cook, Consultant Appendix D: Understanding a Long Regular Expression Understanding a Long Regular Expression The Base Layer Capturing a Character Quantifiers Final Breakdown Appendix E: Regular Expression Enabled Languages Appendix F: Sample Data Analysis Questions Appendix G: Formats Recognized by Lubridate Appendix H: Other Books by Bill Yarberry Index
دانلود کتاب CRAN Recipes : DPLYR, Stringr, Lubridate, and RegEx in R