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 版)
有用的方法
373
12.12.4 另请参阅
有关查看属性的更多信息,请参阅 12.13 节。
12.13 显示对象的结构
12.13.1 问题
调用了一个函数,然后返回结果。现在,你需要查看这个结果并了解更多信息。
12.13.2 解决方案
使用 class 来确定对象类:
class(
x
)
使用 mode 剥离面向对象的特性,揭示数据的潜在结构:
mode(
x
)
使用 str 显示内部结构和内容:
str(
x
)
12.13.3 讨论
很多时候,我们调用一个函数,得到一些结果,然后想知道:“这究竟是什么?”理论上,
函数文档应该解释返回的值,但是当我们自己看到它的结构时,有时候感觉会更好。对
于具有嵌套结构的对象(对象内含有对象)尤其如此。
我们分析 lm(线性建模函数)在最简单的线性回归方法中的返回值,参见 11.1 节:
load(file = './data/conf.rdata')
m <- lm(y ~ x1)
print(m)
#>
#> Call:
#> lm(formula = y ~ x1)
#>
#> Coefficients:
#> (Intercept) x1
#> 15.9 -11.0
我们总是从检查对象的类开始处理数据。类指示它是一个向量、矩阵、列表、数据框还
是对象:
374
12
class(m) ...
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

机器学习实战:基于Scikit-Learn、Keras 和TensorFlow (原书第2 版)

机器学习实战:基于Scikit-Learn、Keras 和TensorFlow (原书第2 版)

Aurélien Géron
大规模数据分析和建模:基于 Spark 与 R

大规模数据分析和建模:基于 Spark 与 R

Javier Luraschi, Kevin Kuo, Edgar Ruiz
管理Kubernetes

管理Kubernetes

Brendan Burns, Craig Tracey

Publisher Resources

ISBN: 9787111656814