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 版)
输入与输出
101
#> 1 label lbound ubound
#> 2 low 0 0.674
#> 3 mid 0.674 1.64
#> 4 high 1.64 2.33
有时将元数据放入文件很方便。如果此元数据以公共字符开头,例如井号(#),则我们
可以使用 comment = FALSE 参数来忽略元数据行。
read_csv 函数有许多有用的设置,其中一些选项及其默认值包括:
na = c("", "NA")
指示哪些值表示缺失值或 NA 值。
comment = ""
指示要作为注释或元数据忽略的行。
trim_ws = TRUE
指示是否在字段的开头和结尾处删除空格。
skip = 0
指示要在文件开头跳过的行数。
guess_max = min(1000, n_max)
指示导入列类型时要考虑的行数。
有关所有可用选项的更多详细信息,请参阅 R 帮助页面 help(read_csv)
如果你有一个数据文件使用分号(;)作为分隔符并使用逗号(,)标十进制数,就像在北
美以外常见的那样,那你应该使用 read_csv2 函数,它是为这种情况而构建的。
4.8.4 另请参阅
参见 4.9 节。另请参阅 readr vignettevignette(readr)
4.9 写入 CSV 文件
4.9.1 问题
你希望使用逗号分隔符的格式保存矩阵或数据框。
4.9.2 解决方案
tidyverse readr 包的 write_csv 函数可以写入 CSV 文件:
102
4
library(tidyverse) ...
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