Skip to Content
R 语言经典实例(原书第 2 版)
book

R 语言经典实例(原书第 2 版)

by J.D. Long, Paul Teetor
June 2020
Beginner to intermediate
522 pages
9h 6m
Chinese
China Machine Press
Content preview from R 语言经典实例(原书第 2 版)
数据结构
137
juniors <- c(5, 3, 4, 3, 3)
comb <- stack(list(fresh = freshmen, soph = sophomores, jrs = juniors))
print(comb)
#> values ind
#> 1 1 fresh
#> 2 2 fresh
#> 3 1 fresh
#> 4 1 fresh
#> 5 5 fresh
#> 6 3 soph
#> 7 2 soph
#> 8 3 soph
#> 9 3 soph
#> 10 5 soph
#> 11 5 jrs
#> 12 3 jrs
#> 13 4 jrs
#> 14 3 jrs
#> 15 3 jrs
现在可以对这两列进行 ANOVA 方差分析:
aov(values ~ ind, data = comb)
构建这个列表时,我们必须对列表元素提供标签(在此示例中,标签是 freshsoph
jrs)。由于 stack 函数将标签用作平行因子的水平,所以这些标签是必需的。
5.6 创建列表
5.6.1 问题
需要创建并填充一个列表。
5.6.2 解决方案
要从单个数据项创建列表,可以使用 list 函数:
lst <- list(x, y, z)
5.6.3 讨论
列表可以非常简单,例如下面包含三个数的列表:
lst <- list(0.5, 0.841, 0.977)
lst
#> [[1]]
#> [1] 0.5
138
5
#>
#> [[2]]
#> [1] 0.841
#>
#> [[3]]
#> [1] ...
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

Istio 学习指南

Istio 学习指南

Lee Calcote, Zack Butcher
数据压缩入门

数据压缩入门

Colt McAnlis, Aleks Haecky
Python数据处理

Python数据处理

Jacqueline Kazil, Katharine Jarmul

Publisher Resources

ISBN: 9787111656814