更新时间:2021-07-02 21:31:24
封面
版权信息
Credits
About the Author
About the Reviewer
www.PacktPub.com
Why subscribe?
Customer Feedback
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
Introduction to R
What R is and what it isn't
The inspiration for R – the S language
R is a high quality statistical computing system
R is a flexible programming language
R is free as in freedom and as in free beer
What R is not good for
Comparing R with other software
The interpreter and the console
Tools to work efficiently with R
Pick an IDE or a powerful editor
The send to console functionality
The efficient write-execute loop
Executing R code in non-interactive sessions
How to use this book
Tracking state with symbols and variables
Working with data types and data structures
Numerics
Special values
Characters
Logicals
Vectors
Factors
Matrices
Lists
Data frames
Divide and conquer with functions
Optional arguments
Functions as arguments
Operators are functions
Coercion
Complex logic with control structures
If… else conditionals
For loops
While loops
The examples in this book
Summary
Understanding Votes with Descriptive Statistics
This chapter's required packages
The Brexit votes example
Cleaning and setting up the data
Summarizing the data into a data frame
Getting intuition with graphs and correlations
Visualizing variable distributions
Using matrix scatter plots for a quick overview
Getting a better look with detailed scatter plots
Understanding interactions with correlations
Creating a new dataset with what we've learned
Building new variables with principal components
Putting it all together into high-quality code
Planning before programming
Understanding the fundamentals of high-quality code
Programming by visualizing the big picture
Predicting Votes with Linear Models
Required packages
Setting up the data
Training and testing datasets
Predicting votes with linear models
Checking model assumptions
Checking linearity with scatter plots
Checking normality with histograms and quantile-quantile plots
Checking homoscedasticity with residual plots
Checking no collinearity with correlations
Measuring accuracy with score functions
Programatically finding the best model
Generating model combinations
Predicting votes from wards with unknown data
Simulating Sales Data and Working with Databases
Designing our data tables
The basic variables
Simplifying assumptions
Potential pitfalls
The too-much-empty-space problem
The too-much-repeated-data problem
Simulating the sales data
Simulating numeric data according to distribution assumptions
Simulating categorical values using factors