Learn R As a Language

Learning a computer language like R can be either frustrating, fun, or boring. Having fun requires challenges that wake up the learner’s curiosity but also provide an emotional reward on overcoming them. This book is designed so that it includes smaller and bigger challenges, in what I call playgrou...

Celý popis

Uloženo v:
Podrobná bibliografie
Hlavní autor: Aphalo, Pedro J.
Médium: E-kniha Kniha
Jazyk:angličtina
Vydáno: Boca Raton CRC Press 2020
CRC Press LLC
Vydání:1
Edice:Chapman & Hall/CRC The R Series
Témata:
ISBN:0367182556, 036718253X, 9780367182533, 9780367182557
On-line přístup:Získat plný text
Tagy: Přidat tag
Žádné tagy, Buďte první, kdo vytvoří štítek k tomuto záznamu!
Obsah:
  • 7.14.3 Using functions as building blocks -- 7.15 Generating output files -- 7.16 Further reading -- 8 Data import and export -- 8.1 Aims of this chapter -- 8.2 Introduction -- 8.3 Packages used in this chapter -- 8.4 File names and operations -- 8.5 Opening and closing file connections -- 8.6 Plain-text files -- 8.6.1 Base R and 'utils' -- 8.6.2 readr -- 8.7 XML and HTML files -- 8.7.1 'xml2' -- 8.8 GPX files -- 8.9 Worksheets -- 8.9.1 CSV files as middlemen -- 8.9.2 'readxl' -- 8.9.3 'xlsx' -- 8.9.4 'readODS' -- 8.10 Statistical software -- 8.10.1 foreign -- 8.10.2 haven -- 8.11 NetCDF files -- 8.11.1 ncdf4 -- 8.11.2 tidync -- 8.12 Remotely located data -- 8.13 Data acquisition from physical devices -- 8.13.1 jsonlite -- 8.14 Databases -- 8.15 Further reading -- Bibliography -- General index -- Index of R names by category -- Alphabetic index of R names
  • 3.3.2.1 Non-vectorized if, else and switch -- 3.3.2.2 Vectorized ifelse() -- 3.3.3 Iteration -- 3.3.3.1 for loops -- 3.3.3.2 while loops -- 3.3.3.3 repeat loops -- 3.3.4 Explicit loops can be slow in R -- 3.3.5 Nesting of loops -- 3.3.5.1 Clean-up -- 3.4 Apply functions -- 3.4.1 Applying functions to vectors and lists -- 3.4.2 Applying functions to matrices and arrays -- 3.5 Object names and character strings -- 3.6 The multiple faces of loops -- 3.6.1 Further reading -- 4 The R language: Statistics -- 4.1 Aims of this chapter -- 4.2 Statistical summaries -- 4.3 Distributions -- 4.3.1 Density from parameters -- 4.3.2 Probabilities from parameters and quantiles -- 4.3.3 Quantiles from parameters and probabilities -- 4.3.4 "Random" draws from a distribution -- 4.4 "Random" sampling -- 4.5 Correlation -- 4.5.1 Pearson's r -- 4.5.2 Kendall's τ and Spearman's ρ -- 4.6 Fitting linear models -- 4.6.1 Regression -- 4.6.2 Analysis of variance, ANOVA -- 4.6.3 Analysis of covariance, ANCOVA -- 4.7 Generalized linear models -- 4.8 Non-linear regression -- 4.9 Model formulas -- 4.10 Time series -- 4.11 Multivariate statistics -- 4.11.1 Multivariate analysis of variance -- 4.11.2 Principal components analysis -- 4.11.3 Multidimensional scaling -- 4.11.4 Cluster analysis -- 4.12 Further reading -- 5 The R language: Adding new "words" -- 5.1 Aims of this chapter -- 5.2 Packages -- 5.2.1 Sharing of R-language extensions -- 5.2.2 How packages work -- 5.2.3 Download, installation and use -- 5.2.4 Finding suitable packages -- 5.3 Defining functions and operators -- 5.3.1 Ordinary functions -- 5.3.2 Operators -- 5.4 Objects, classes, and methods -- 5.5 Scope of names -- 5.6 Further reading -- 6 New grammars of data -- 6.1 Aims of this chapter -- 6.2 Introduction -- 6.3 Packages used in this chapter -- 6.4 Replacements for data.frame -- 6.4.1 'data.table'
  • 6.4.2 'tibble' -- 6.5 Data pipes -- 6.5.1 'magrittr' -- 6.5.2 'wrapr' -- 6.6 Reshaping with 'tidyr' -- 6.7 Data manipulation with 'dplyr' -- 6.7.1 Row-wise manipulations -- 6.7.2 Group-wise manipulations -- 6.7.3 Joins -- 6.8 Further reading -- 7 Grammar of graphics -- 7.1 Aims of this chapter -- 7.2 Packages used in this chapter -- 7.3 Introduction to the grammar of graphics -- 7.3.1 Data -- 7.3.2 Mapping -- 7.3.3 Geometries -- 7.3.4 Statistics -- 7.3.5 Scales -- 7.3.6 Coordinate systems -- 7.3.7 Themes -- 7.3.8 Plot construction -- 7.3.9 Plots as R objects -- 7.3.10 Data and mappings -- 7.4 Geometries -- 7.4.1 Point -- 7.4.2 Rug -- 7.4.3 Line and area -- 7.4.4 Column -- 7.4.5 Tiles -- 7.4.6 Simple features (sf) -- 7.4.7 Text -- 7.4.8 Plot insets -- 7.5 Statistics -- 7.5.1 Functions -- 7.5.2 Summaries -- 7.5.3 Smoothers and models -- 7.5.4 Frequencies and counts -- 7.5.5 Density functions -- 7.5.6 Box and whiskers plots -- 7.5.7 Violin plots -- 7.6 Facets -- 7.7 Scales -- 7.7.1 Axis and key labels -- 7.7.2 Continuous scales -- 7.7.2.1 Limits -- 7.7.2.2 Ticks and their labels -- 7.7.2.3 Transformed scales -- 7.7.2.4 Position of x and y axes -- 7.7.2.5 Secondary axes -- 7.7.3 Time and date scales for x and y -- 7.7.4 Discrete scales for x and y -- 7.7.5 Size -- 7.7.6 Color and fill -- 7.7.6.1 Color definitions in R -- 7.7.7 Continuous color-related scales -- 7.7.8 Discrete color-related scales -- 7.7.9 Identity scales -- 7.8 Adding annotations -- 7.9 Coordinates and circular plots -- 7.9.1 Wind-rose plots -- 7.9.2 Pie charts -- 7.10 Themes -- 7.10.1 Complete themes -- 7.10.2 Incomplete themes -- 7.10.3 Defining a new theme -- 7.11 Composing plots -- 7.12 Using plotmath expressions -- 7.13 Creating complex data displays -- 7.14 Creating sets of plots -- 7.14.1 Saving plot layers and scales in variables -- 7.14.2 Saving plot layers and scales in lists
  • Cover -- Half Title -- Title Page -- Copyright Page -- Table of Contents -- Preface -- 1 R: The language and the program -- 1.1 Aims of this chapter -- 1.2 R -- 1.2.1 What is R? -- 1.2.2 R as a language -- 1.2.3 R as a computer program -- 1.2.3.1 Using R interactively -- 1.2.3.2 Using R in a "batch job" -- 1.2.3.3 Editors and IDEs -- 1.3 Reproducible data analysis -- 1.4 Finding additional information -- 1.4.1 R's built-in help -- 1.4.2 Obtaining help from online forums -- 1.4.2.1 Netiquette -- 1.4.2.2 StackOverflow -- 1.4.2.3 Reporting bugs -- 1.5 What is needed to run the examples in this book? -- 1.6 Further reading -- 2 The R language: "Words" and "sentences" -- 2.1 Aims of this chapter -- 2.2 Natural and computer languages -- 2.3 Numeric values and arithmetic -- 2.4 Logical values and Boolean algebra -- 2.5 Comparison operators and operations -- 2.6 Sets and set operations -- 2.7 Character values -- 2.8 The 'mode' and 'class' of objects -- 2.9 'Type' conversions -- 2.10 Vector manipulation -- 2.11 Matrices and multidimensional arrays -- 2.12 Factors -- 2.13 Lists -- 2.13.1 Member extraction and subsetting -- 2.13.2 Adding and removing list members -- 2.13.3 Nested lists -- 2.14 Data frames -- 2.14.1 Operating within data frames -- 2.14.2 Re-arranging columns and rows -- 2.15 Attributes of R objects -- 2.16 Saving and loading data -- 2.16.1 Data sets in R and packages -- 2.16.2 .rda files -- 2.16.3 .rds files -- 2.17 Looking at data -- 2.18 Plotting -- 2.19 Further reading -- 3 The R language: "Paragraphs" and "essays" -- 3.1 Aims of this chapter -- 3.2 Writing scripts -- 3.2.1 What is a script? -- 3.2.2 How do we use a script? -- 3.2.3 How to write a script -- 3.2.4 The need to be understandable to people -- 3.2.5 Debugging scripts -- 3.3 Control of execution flow -- 3.3.1 Compound statements -- 3.3.2 Conditional execution