ebook img

R For Dummies PDF

450 Pages·2013·3.81 MB·English
by  
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview R For Dummies

R For Dummies® Visit www.dummies.com/cheatsheet/ruk to view this book's cheat sheet. Table of Contents Introduction About This Book Conventions Used in This Book What You’re Not to Read Foolish Assumptions How This Book Is Organized Part I: R You Ready? Part II: Getting Down to Work in R Part III: Coding in R Part IV: Making the Data Talk Part V: Working with Graphics Part VI: The Part of Tens Icons Used in This Book Where to Go from Here Part I: R You Ready? Chapter 1: Introducing R: The Big Picture Recognizing the Benefits of Using R It comes as free, open-source code It runs anywhere It supports extensions It provides an engaged community It connects with other languages Looking At Some of the Unique Features of R Performing multiple calculations with vectors Processing more than just statistics Running code without a compiler Chapter 2: Exploring R Working with a Code Editor Exploring RGui Dressing up with RStudio Starting Your First R Session Saying hello to the world Doing simple math Using vectors Storing and calculating values Talking back to the user Sourcing a Script Navigating the Workspace Manipulating the content of the workspace Saving your work Retrieving your work Chapter 3: The Fundamentals of R Using the Full Power of Functions Vectorizing your functions Putting the argument in a function Making history Keeping Your Code Readable Following naming conventions Structuring your code Adding comments Getting from Base R to More Finding packages Installing packages Loading and unloading packages Part II: Getting Down to Work in R Chapter 4: Getting Started with Arithmetic Working with Numbers, Infinity, and Missing Values Doing basic arithmetic Using mathematical functions Calculating whole vectors To infinity and beyond Organizing Data in Vectors Discovering the properties of vectors Creating vectors Combining vectors Repeating vectors Getting Values in and out of Vectors Understanding indexing in R Extracting values from a vector Changing values in a vector Working with Logical Vectors Comparing values Using logical vectors as indices Combining logical statements Summarizing logical vectors Powering Up Your Math with Vector Functions Using arithmetic vector operations Recycling arguments Chapter 5: Getting Started with Reading and Writing Using Character Vectors for Text Data Assigning a value to a character vector Creating a character vector with more than one element Extracting a subset of a vector Naming the values in your vectors Manipulating Text String theory: Combining and splitting strings Sorting text Finding text inside text Substituting text Revving up with regular expressions Factoring in Factors Creating a factor Converting a factor Looking at levels Distinguishing data types Working with ordered factors Chapter 6: Going on a Date with R Working with Dates Presenting Dates in Different Formats Adding Time Information to Dates Formatting Dates and Times Performing Operations on Dates and Times Addition and subtraction Comparison of dates Extraction Chapter 7: Working in More Dimensions Adding a Second Dimension Discovering a new dimension Combining vectors into a matrix Using the Indices Extracting values from a matrix Replacing values in a matrix Naming Matrix Rows and Columns Changing the row and column names Using names as indices Calculating with Matrices Using standard operations with matrices Calculating row and column summaries Doing matrix arithmetic Adding More Dimensions Creating an array Using dimensions to extract values Combining Different Types of Values in a Data Frame Creating a data frame from a matrix Creating a data frame from scratch Naming variables and observations Manipulating Values in a Data Frame Extracting variables, observations, and values Adding observations to a data frame Adding variables to a data frame Combining Different Objects in a List Creating a list Extracting elements from lists Changing the elements in lists Reading the output of str() for lists Seeing the forest through the trees Part III: Coding in R Chapter 8: Putting the Fun in Functions Moving from Scripts to Functions Making the script Transforming the script Using the function Reducing the number of lines Using Arguments the Smart Way Adding more arguments Conjuring tricks with dots Using functions as arguments Coping with Scoping Crossing the borders Using internal functions Dispatching to a Method Finding the methods behind the function Doing it yourself Chapter 9: Controlling the Logical Flow Making Choices with if Statements Doing Something Else with an if...else Statement Vectorizing Choices Looking at the problem Choosing based on a logical vector Making Multiple Choices Chaining if...else statements Switching between possibilities Looping Through Values Constructing a for loop Calculating values in a for loop Looping without Loops: Meeting the Apply Family Looking at the family features Meeting three of the members Applying functions on rows and columns Applying functions to listlike objects Chapter 10: Debugging Your Code Knowing What to Look For Reading Errors and Warnings Reading error messages Caring about warnings (or not) Going Bug Hunting Calculating the logit Knowing where an error comes from Looking inside a function Generating Your Own Messages Creating errors Creating warnings Recognizing the Mistakes You’re Sure to Make Starting with the wrong data Having your data in the wrong format Chapter 11: Getting Help Finding Information in the R Help Files When you know exactly what you’re looking for When you don’t know exactly what you’re looking for Searching the Web for Help with R Getting Involved in the R Community Using the R mailing lists Discussing R on Stack Overflow and Stack Exchange Tweeting about R Making a Minimal Reproducible Example Creating sample data with random values Producing minimal code Providing the necessary information Part IV: Making the Data Talk Chapter 12: Getting Data into and out of R Getting Data into R Entering data in the R text editor Using the Clipboard to copy and paste Reading data in CSV files Reading data from Excel Working with other data types Getting Your Data out of R Working with Files and Folders Understanding the working directory Manipulating files Chapter 13: Manipulating and Processing Data Deciding on the Most Appropriate Data Structure Creating Subsets of Your Data Understanding the three subset operators Understanding the five ways of specifying the subset Subsetting data frames Adding Calculated Fields to Data Doing arithmetic on columns of a data frame Using with and within to improve code readability Creating subgroups or bins of data Combining and Merging Data Sets Creating sample data to illustrate merging Using the merge() function Working with lookup tables Sorting and Ordering Data Sorting vectors Sorting data frames Traversing Your Data with the Apply Functions Using the apply() function to summarize arrays Using lapply() and sapply() to traverse a list or data frame Using tapply() to create tabular summaries Getting to Know the Formula Interface Whipping Your Data into Shape Understanding data in long and wide format Getting started with the reshape2 package Melting data to long format Casting data to wide format Chapter 14: Summarizing Data Starting with the Right Data Using factors or numeric data Counting unique values Preparing the data Describing Continuous Variables Talking about the center of your data Describing the variation Checking the quantiles Describing Categories Counting appearances Calculating proportions Finding the center Describing Distributions Plotting histograms Using frequencies or densities Describing Multiple Variables Summarizing a complete dataset Plotting quantiles for subgroups Tracking correlations Working with Tables Creating a two-way table Converting tables to a data frame Looking at margins and proportions Chapter 15: Testing Differences and Relations Taking a Closer Look at Distributions Observing beavers Testing normality graphically Using quantile plots Testing normality in a formal way Comparing Two Samples Testing differences Comparing paired data Testing Counts and Proportions Checking out proportions Analyzing tables Extracting test results Working with Models Analyzing variances Evaluating the differences Modeling linear relations Evaluating linear models Predicting new values Part V: Working with Graphics Chapter 16: Using Base Graphics Creating Different Types of Plots Getting an overview of plot Adding points and lines to a plot Different plot types Controlling Plot Options and Arguments Adding titles and axis labels Changing plot options Putting multiple plots on a single page Saving Graphics to Image Files Chapter 17: Creating Faceted Graphics with Lattice Creating a Lattice Plot Loading the lattice package Making a lattice scatterplot Adding trend lines Changing Plot Options Adding titles and labels Changing the font size of titles and labels Using themes to modify plot options Plotting Different Types Making a bar chart Making a box-and-whisker plot Plotting Data in Groups Using data in tall format Creating a chart with groups Adding a key Printing and Saving a Lattice Plot Assigning a lattice plot to an object Printing a lattice plot in a script Saving a lattice plot to file Chapter 18: Looking At ggplot2 Graphics Installing and Loading ggplot2 Looking At Layers Using Geoms and Stats Defining what data to use Mapping data to plot aesthetics Getting geoms Sussing Stats Adding Facets, Scales, and Options Adding facets Changing options Getting More Information Part VI: The Part of Tens Chapter 19: Ten Things You Can Do in R That You Would’ve Done in Microsoft Excel Adding Row and Column Totals Formatting Numbers Sorting Data Making Choices with If Calculating Conditional Totals Transposing Columns or Rows Finding Unique or Duplicated Values Working with Lookup Tables Working with Pivot Tables Using the Goal Seek and Solver Chapter 20: Ten Tips on Working with Packages Poking Around the Nooks and Crannies of CRAN Finding Interesting Packages Installing Packages Loading Packages Reading the Package Manual and Vignette Updating Packages Unloading Packages Forging Ahead with R-Forge Conducting Installations from BioConductor Reading the R Manual Appendix: Installing R and RStudio Installing and Configuring R Installing R Configuring R Installing RStudio Configuring RStudio Cheat Sheet R For Dummies® by Andrie de Vries and Joris Meys R For Dummies® Published by John Wiley & Sons, Ltd The Atrium Southern Gate Chichester West Sussex PO19 8SQ England Email (for orders and customer service enquires):

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.