Convert Figma logo to code with AI

hadley logor4ds

R for data science: a book

4,509
4,189
4,509
34

Top Related Projects

Authoring Books and Technical Documents with R Markdown

Dynamic Documents for R

Quick Overview

R for Data Science (R4DS) is a comprehensive guide and accompanying repository for learning data science using R. It covers the entire data science workflow, from importing and tidying data to visualization and modeling. The book and repository serve as both an educational resource and a practical reference for data scientists at various skill levels.

Pros

  • Comprehensive coverage of data science concepts and R programming
  • Regularly updated content to reflect current best practices and new R packages
  • Free and open-source, making it accessible to a wide audience
  • Includes practical exercises and example datasets for hands-on learning

Cons

  • May be overwhelming for complete beginners due to the breadth of content
  • Some advanced topics might require additional resources or background knowledge
  • Focuses primarily on the tidyverse ecosystem, which may not cover all R approaches
  • Updates to the book can sometimes lag behind the latest package versions

Code Examples

  1. Data import and basic manipulation:
library(tidyverse)
data <- read_csv("data.csv")
summary(data)
  1. Data visualization with ggplot2:
ggplot(data, aes(x = x_variable, y = y_variable)) +
  geom_point() +
  labs(title = "Scatter Plot", x = "X Variable", y = "Y Variable")
  1. Data transformation with dplyr:
data %>%
  filter(condition == TRUE) %>%
  group_by(category) %>%
  summarize(mean_value = mean(numeric_column, na.rm = TRUE))

Getting Started

To get started with R4DS:

  1. Install R and RStudio
  2. Install required packages:
install.packages(c("tidyverse", "nycflights13", "gapminder", "Lahman"))
  1. Clone the repository:
git clone https://github.com/hadley/r4ds.git
  1. Open the R4DS project in RStudio and start exploring the chapters and exercises.

Competitor Comparisons

Authoring Books and Technical Documents with R Markdown

Pros of bookdown

  • Focused on creating books and long-form documentation
  • Supports multiple output formats (HTML, PDF, ePub)
  • Extensive customization options for book structure and appearance

Cons of bookdown

  • Steeper learning curve for non-technical users
  • Less emphasis on data science concepts and practical examples
  • Requires more setup and configuration for basic usage

Code Comparison

r4ds:

library(tidyverse)
ggplot(mpg, aes(displ, hwy, colour = class)) + 
  geom_point()

bookdown:

bookdown::render_book("index.Rmd", "bookdown::gitbook")

Summary

r4ds is a comprehensive guide to data science with R, offering practical examples and exercises. bookdown, on the other hand, is a powerful tool for creating books and long-form documentation with R Markdown. While r4ds focuses on teaching data science concepts, bookdown provides a framework for authoring and publishing content in various formats. The choice between the two depends on whether you're looking to learn data science or create documentation and books using R.

Dynamic Documents for R

Pros of rmarkdown

  • Focused on a specific tool for literate programming and reproducible research
  • More comprehensive documentation on R Markdown features and syntax
  • Actively maintained by RStudio, ensuring compatibility with their IDE

Cons of rmarkdown

  • Narrower scope, primarily covering R Markdown functionality
  • Less emphasis on general data science concepts and workflows
  • May be less accessible for complete beginners to R and data analysis

Code Comparison

r4ds example:

ggplot(data = mpg) + 
  geom_point(mapping = aes(x = displ, y = hwy, color = class))

rmarkdown example:

---
title: "My Report"
output: html_document
---

```{r}
summary(cars)

### Summary

r4ds is a comprehensive resource for learning data science with R, covering a wide range of topics and tools. rmarkdown, on the other hand, focuses specifically on R Markdown, providing in-depth documentation and examples for creating dynamic documents. While r4ds offers a broader introduction to data science concepts, rmarkdown is more suitable for those looking to master R Markdown for reproducible research and report generation.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

R for Data Science

Render and deploy Book to Netlify

This repository contains the source of R for Data Science book. The book is built using Quarto.

Images

Omnigraffle drawings

  • Font: 12pt Guardian Sans Condensed / Ubuntu mono

  • Export as 300 dpi png.

  • Website font is 18 px = 13.5 pt, so scale dpi to match font sizes: 270 = 300 * 12 / 13.5. (I also verified this empirically by screenshotting.)

    #| echo: FALSE
    #| out.width: NULL
    knitr::include_graphics("diagrams/transform.png", dpi = 270)
    

Screenshots

  • Make sure you're using a light theme. For small interface elements (eg. toolbars), zoom in twice.

  • Screenshot with Cmd + Shift + 4.

  • Don't need to set dpi:

    #| echo: FALSE
    #| out.width: NULL
    knitr::include_graphics("screenshots/rstudio-wg.png")
    

O'Reilly

To generate book for O'Reilly, build the book then:

# pak::pak("hadley/htmlbook")
htmlbook::convert_book()

html <- list.files("oreilly", pattern = "[.]html$", full.names = TRUE)
file.copy(html, "../r-for-data-science-2e/", overwrite = TRUE)

pngs <- list.files("oreilly", pattern = "[.]png$", full.names = TRUE, recursive = TRUE)
dest <- gsub("oreilly", "../r-for-data-science-2e/", pngs)
fs::dir_create(unique(dirname(dest)))
file.copy(pngs, dest, overwrite = TRUE)

Then commit and push to atlas.

Code of Conduct

Please note that r4ds uses a Contributor Code of Conduct. By contributing to this book, you agree to abide by its terms.