Skip to Content
R在数据科学中的应用,第2版
book

R在数据科学中的应用,第2版

by Hadley Wickham, Mine Cetinkaya-Rundel, Garrett Grolemund
May 2025
Intermediate to advanced
578 pages
8h 9m
Chinese
O'Reilly Media, Inc.
Content preview from R在数据科学中的应用,第2版

第 28 章 四开本

本作品已使用人工智能进行翻译。欢迎您提供反馈和意见:translation-feedback@oreilly.com

导言

Quarto 为数据科学提供了一个统一的写作框架,将你的代码、结果和散文结合在一起。Quarto 文档可完全复制,并支持 PDF、Word 文件、演示文稿等数十种输出格式。

Quarto 文件有三种使用方式:

  • 用于与决策者沟通,决策者希望关注结论,而不是分析背后的代码

  • 用于与其他数据科学家(包括未来的你!)合作,他们对你的结论和得出结论的方式(即代码)都很感兴趣

  • 作为进行数据科学研究的环境,作为现代实验笔记本,您不仅可以记录您所做的事情,还可以记录您的想法

Quarto 是一款命令行界面工具,而不是 R 软件包。这意味着帮助基本上不能通过? 获取。因此,在学习本章和将来使用 Quarto 时,应参考Quarto 文档

如果您是 R Markdown 用户,您可能会想:"Quarto 听起来很像 R Markdown"。你没有想错!Quarto 将 R Markdown 生态系统中的许多软件包(rmarkdown、bookdown、distill、xaringan 等)的功能统一到一个统一的系统中,并对其进行了扩展,除 R 语言外,还支持 Python 和 Julia 等多种编程语言。

先决条件

您需要使用 Quarto 命令行界面(Quarto CLI),但不需要明确安装或加载,因为 RStudio 会在需要时自动安装或加载。

四开本基础知识

这是一个 Quarto 文件--扩展名为.qmd 的纯文本文件:

---
title: "Diamond sizes"
date: 2022-09-12
format: html
---

```{r}
#| label: setup
#| include: false

library(tidyverse)

smaller <- diamonds |> 
  filter(carat <= 2.5)
```

We have data about `r nrow(diamonds)` diamonds.
Only `r nrow(diamonds) - nrow(smaller)` are larger than 2.5 carats.
The distribution of the remainder is shown below:

```{r}
#| label: plot-smaller-diamonds
#| echo: false

smaller |> 
  ggplot(aes(x = carat)) + 
  geom_freqpoly(binwidth = 0.01)
```

它包含三类重要内容:

  • 一个YAML 标头(可选),周围用---
  • ```
  • 混合了简单文本格式的文本,如# heading_italics_

图 28-1显示了 RStudio 中.qmd 文档的笔记本界面,其中代码和输出交错排列。您可以单击运行图标(Run)(它看起来像位于代码块顶部的播放按钮)或按下 Cmd/Ctrl+Shift+Enter 来运行每个代码块。RStudio 会执行代码并将结果与代码联机显示。

RStudio window with a Quarto document titled "diamond-sizes.qmd" on the left and a blank Viewer window on the right. The Quarto document has a code chunk that creates a frequency plot of diamonds that weigh less than 2.5 carats. The plot shows that the frequency decreases as the weight increases.
图 28-1. RStudio 中的 Quarto ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

R深度学习权威指南

R深度学习权威指南

Posts & Telecom Press, Joshua F. Wiley
AI工程

AI工程

Chip Huyen
Raku学习手册

Raku学习手册

brian d foy

Publisher Resources

ISBN: 9798341657304