R for Data Science
http://r4ds.had.co.nz/ <- – https://bookdown.org/
Garrett Grolemund, Hadley Wickham
http://tidyverse.org/
https://github.com/hadley/r4ds
http://style.tidyverse.org/
library(tidyverse)
로 tidyverse의 핵심 팩키지를 한번에 loading할수 있다.
- ggplot2, for data visualisation.
- dplyr, for data manipulation.
- tidyr, for data tidying.
- readr, for data import.
- purrr, for functional programming.
- tibble, for tibbles, a modern re-imagining of data frames
> library(tidyverse) Loading tidyverse: ggplot2 Loading tidyverse: tibble Loading tidyverse: tidyr Loading tidyverse: readr Loading tidyverse: purrr Loading tidyverse: dplyr Conflicts with tidy packages ------------------------ filter(): dplyr, stats lag(): dplyr, stats
> tidyverse_conflicts() Conflicts with tidy packages ------------------------------ filter(): dplyr, stats lag(): dplyr, stats
> tidyverse_packages()
[1] "broom" "dplyr" "forcats" "ggplot2" "haven" "httr" "hms" "jsonlite" [9] "lubridate" "magrittr" "modelr" "purrr" "readr" "readxl" "stringr" "tibble" [17] "rvest" "tidyr" "xml2" "tidyverse"
> tidyverse_deps()
# A tibble: 19 × 4 package cran local behind <chr> <chr> <chr> <lgl> 1 broom 0.4.2 0.4.2 FALSE 2 dplyr 0.7.0 0.5.0 TRUE 3 forcats 0.2.0 0.2.0 FALSE 4 ggplot2 2.2.1 2.2.1 FALSE 5 haven 1.0.0 1.0.0 FALSE 6 hms 0.3 0.3 FALSE 7 httr 1.2.1 1.2.1 FALSE 8 jsonlite 1.5 1.4 TRUE 9 lubridate 1.6.0 1.6.0 FALSE 10 magrittr 1.5 1.5 FALSE 11 modelr 0.1.0 0.1.0 FALSE 12 purrr 0.2.2.2 0.2.2 TRUE 13 readr 1.1.1 1.1.1 FALSE 14 readxl 1.0.0 1.0.0 FALSE 15 rvest 0.3.2 0.3.2 FALSE 16 stringr 1.2.0 1.2.0 FALSE 17 tibble 1.3.3 1.2 TRUE 18 tidyr 0.6.3 0.6.1 TRUE 19 xml2 1.1.1 1.1.1 FALSE
Update
> tidyverse_update() The following packages are out of date: * dplyr (0.5.0 -> 0.7.0) * jsonlite (1.4 -> 1.5) * purrr (0.2.2 -> 0.2.2.2) * tibble (1.2 -> 1.3.3) * tidyr (0.6.1 -> 0.6.3) Update now? 1: Yes 2: No Selection: 1 also installing the dependencies ‘bindr’, ‘bindrcpp’, ‘glue’, ‘pkgconfig’, ‘rlang’
- Wrangle—transform your datasets into a form convenient for analysis
- Program—learn powerful R tools for solving data problems with greater clarity and ease
- Explore—examine your data, generate hypotheses, and quickly test them
- Model—provide a low-dimensional summary that captures true “signals” in your dataset
- Communicate—learn R Markdown for integrating prose, code, and results
Chapter 1 Data Visualization with ggplot2
- Introduction
- First Steps
- Aesthetic Mappings
- Common Problems
- Facets
- Geometric Objects
- Statistical Transformations
- Position Adjustments
- Coordinate Systems
- The Layered Grammar of Graphics
Chapter 2 Workflow: Basics
- Coding Basics
- What’s in a Name?
- Calling Functions
Chapter 3 Data Transformation with dplyr
- Introduction
- Filter Rows with filter()
- Arrange Rows with arrange()
- Select Columns with select()
- Add New Variables with mutate()
- Grouped Summaries with summarize()
- Grouped Mutates (and Filters)
Chapter 4 Workflow: Scripts
- Running Code
- RStudio Diagnostics
Chapter 5 Exploratory Data Analysis
- Intro
- Questions
- Variation
- Missing Values
- Covariation
- Patterns and Models
- ggplot2 Calls
- Learning More
Chapter 6 Workflow: Projects
- What Is Real?
- Where Does Your Analysis Live?
- Paths and Directories
- RStudio Projects
- Summary
Wrangle
Chapter 7 Tibbles with tibble
- Introduction
- Creating Tibbles
- Tibbles Versus data.frame
- Interacting with Older Code
Chapter 8 Data Import with readr
- Introduction
- Getting Started
- Parsing a Vector
- Parsing a File
- Writing to a File
- Other Types of Data
Chapter 9 Tidy Data with tidyr
- Introduction
- Tidy Data
- Spreading and Gathering
- Separating and Pull
- Missing Values
- Case Study
- Nontidy Data
Chapter 10 Relational Data with dplyr
- Introduction
- nycflights13
- Keys
- Mutating Joins
- Filtering Joins
- Join Problems
- Set Operations
Chapter 11 Strings with stringr
- Introduction
- String Basics
- Matching Patterns with Regular Expressions
- Tools
- Other Types of Pattern
- Other Uses of Regular Expressions
- stringi
Chapter 12 Factors with forcats
- Introduction
- Creating Factors
- General Social Survey
- Modifying Factor Order
- Modifying Factor Levels
Chapter 13 Dates and Times with lubridate
- Introduction
- Creating Date/Times
- Date-Time Components
- Time Spans
- Time Zones
Program
Chapter 14 Pipes with magrittr
- Introduction
- Piping Alternatives
- When Not to Use the Pipe
- Other Tools from magrittr
Chapter 15 Functions
- Introduction
- When Should You Write a Function?
- Functions Are for Humans and Computers
- Conditional Execution
- Function Arguments
- Return Values
- Environment
Chapter 16 Vectors
- Introduction
- Vector Basics
- Important Types of Atomic Vector
- Using Atomic Vectors
- Recursive Vectors (Lists)
- Attributes
- Augmented Vectors
Chapter 17 Iteration with purrr
- Introduction
- For Loops
- For Loop Variations
- For Loops Versus Functionals
- The Map Functions
- Dealing with Failure
- Mapping over Multiple Arguments
- Walk
- Other Patterns of For Loops
Model
Chapter 18 Model Basics with modelr
- Introduction
- A Simple Model
- Visualizing Models
- Formulas and Model Families
- Missing Values
- Other Model Families
Chapter 19 Model Building
- Introduction
- Why Are Low-Quality Diamonds More Expensive?
- What Affects the Number of Daily Flights?
- Learning More About Models
Chapter 20 Many Models with purrr and broom
- Introduction
- gapminder
- List-Columns
- Creating List-Columns
- Simplifying List-Columns
- Making Tidy Data with broom
Communicate
Chapter 21 R Markdown
- Introduction
- R Markdown Basics
- Text Formatting with Markdown
- Code Chunks
- Troubleshooting
- YAML Header
- Learning More
Chapter 22 Graphics for Communication with ggplot2
- Introduction
- Label
- Annotations
- Scales
- Zooming
- Themes
- Saving Your Plots
- Learning More
Chapter 23 R Markdown Formats
- Introduction
- Output Options
- Documents
- Notebooks
- Presentations
- Dashboards
- Interactivity
- Websites
- Other Formats
- Learning More
Chapter 24 R Markdown Workflow