Skip to Content
高效R语言编程
book

高效R语言编程

by Colin Gillespie, Robin Lovelace
August 2018
Intermediate to advanced
227 pages
4h 16m
Chinese
China Electric Power Press Ltd.
Content preview from 高效R语言编程
70
3
其他资源
几乎每本
R
书都有一节是关于
apply
函数的。下面是一些我们认为最有帮助
的资源:
每个函数在关联的帮助页中都有一些例程。可使用
example()
函数直接访
问这些例子。例如使用
example(
"
apply
"
)
运行
apply()
的实例。
Stack Overflow
网站上详细描述了何时、何地、如何使用每个函数。
类似地,
Neil Saunders
有一个不错的博客给出了所有
apply
函数的概述。
apply
函数族是函数式编程的。
Grolemund
Wickham
O
Reilly
)编
著的《
R for Data Science
》一书的第
16
章详细讲解了循环和函数式编程
之间的交叉作用,
Hadley Wickham
编著的《
Advanced R
》对该主题进入
了更深入的研究。
练习
1.
使用 vapply() 函数重写先前的 sapply() 函数来确保类型一致性。
2.
你如何确保使用
[ 截取的数据集子集的类型一致性?提示:查看下拉参数。
缓存变量
只计算对象一次并在需要时重用结果是提高代码速度的简单直接的方法。这
就像多个函数需调用 sd(x),那么就调用一次并将结果计入 sd_x,需调用
sd_x ,重 sd(x) 就行。例如,假设我们希望标准化矩阵的每一列。我们
可以使用整个数据集的标准偏差,而不是每一列的标准方差。
apply(x, 2, function(i) mean(i) / sd(x))
这样做是效率很低,因 sd(x) 是常量,所以不必为每行重复计算标准方差。 ...
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进行数据清理、分析与可视化

迈克尔 弗里曼, 乔尔 罗斯
R数据科学

R数据科学

Hadley Wickham, Garrett Grolemund

Publisher Resources

ISBN: 9787519820855