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 版)
187
7
字符串和日期
字符串?日期?在统计软件包中?
只要读取文件或打印报告,你就需要字符串。当你处理现实世界的问题时,你就需要日期。
R 具备处理字符串和日期的功能。R 的字符串功能与面向字符串处理的编程语言(如
Perl 语言)相比,显得很笨拙。但是这是一个不同工作选择不同的适合工具的问题。我
们不会在 Perl 中执行逻辑回归。
tidyverse 中的 stringr 添加包和 lubridate 添加包改进了一些字符串和日期的问题。
与本书的其他章节一样,这里的示例来自基础的 R 以及添加包,这使得学习起来更轻
松、更快捷、更方便。
日期和时间类
R 有各种各样处理日期和时间的类。如果你喜欢有多种选择,这是很好的;但是如果你
喜欢简单地生活,这是烦人的。类之间存在重要区别:一些类是只针对日期的类,一些
是日期时间 (datetime) 类。所有类都可以处理日历日期(例如,2019 3 15 ),
并非所有类都可以表示日期时间(2019 3 1 日上午 11:45 )。
下列类包含在基础 R 中:
Date
Date 类可以表示日历日期,但不能表示时钟时间。它是一个可靠的、通用的类,
用于处理日期,包括转换、格式化、基本日期算法和时区处理。本书中与大多数日
期相关的方法都是基于 Date 类构建的。
POSIXct
这是一个日期时间类,它可以表示精确度为一秒的时刻。在 R 内部,日期时间存储
188
7
1970 1 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

机器学习实战:基于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