函数功能:

write.table prints its required argument x
(after converting it to a data frame if it is not one nor a matrix)
to a file or connection.

将X输出到文件或者链接
函数语法:

write.table(x, file = "", append = FALSE, quote = TRUE, sep = " ",eol = "\n", na = "NA", dec = ".", row.names = TRUE,col.names = TRUE, qmethod = c("escape", "double"),fileEncoding = "")write.csv(...)
write.csv2(...)

函数参数

x
the object to be written, preferably a matrix or data frame.
If not, it is attempted to coerce x to a data frame.

要写入的对象,最好是矩阵或数据框。 如果不是,则尝试将x强制转换为数据框。

file
either a character string naming a file or a connection open for writing.
"" indicates output to the console.

表示文件名的字符串或者链接。“”表示输出到控制台

> studentID <- c(1,2,3,4,5)
> gender <- c('M','F','M','M','F')
> math <- c(40,60,70,60,90)
> English <- c(98,56,78,93,79)
> Chinese <- c(86,54,78,90,98)
> data <- data.frame(studentID,gender,math,English,Chinese,stringsAsFactors = F)
> datastudentID gender math English Chinese
1         1      M   40      98      86
2         2      F   60      56      54
3         3      M   70      78      78
4         4      M   60      93      90
5         5      F   90      79      98
> write.csv(data,"")
"","studentID","gender","math","English","Chinese"
"1",1,"M",40,98,86
"2",2,"F",60,56,54
"3",3,"M",70,78,78
"4",4,"M",60,93,90
"5",5,"F",90,79,98

“” :输出到控制台

append
logical. Only relevant if file is a character string.
If TRUE, the output is appended to the file.
If FALSE, any existing file of the name is destroyed.

逻辑值,当文件名为字符串时(非链接)使用有效,若取值为TRUE,输出结果会新增到原文件中,若取值为FALSE,新输出结果替换原文件。默认取值为FALSE,替换原文件
append=FALSE,默认取值,此时新输出数据将替代原数据


append=TRUE,则在原数据上新增,write.csv无法使用

These wrappers are deliberately inflexible:they are designed to ensure that the correct conventions are used to write a valid file. Attempts to change append, col.names, sep, dec or qmethod are ignored, with a warning.

这些包装程序是故意不灵活的:
它们旨在确保使用正确的约定来写入有效文件。 尝试更改append, col.names, sep, dec or qmethod尝试将被忽略,并显示警告。
write.table函数才可以使用

quote
a logical value (TRUE or FALSE) or a numeric vector.
If TRUE, any character or factor columns will be surrounded by double quotes.
If a numeric vector, its elements are taken as the indices of columns to quote.
In both cases, row and column names are quoted if they are written.
If FALSE, nothing is quoted.

引用
逻辑值(TRUE或FALSE)或数字向量。 如果为TRUE,则任何字符或因子列都将用双引号引起来。 如果是数字矢量,则将其元素用作要引用的列的索引。 在这两种情况下,如果都写了行名和列名,则要加引号。 如果为FALSE,则不引用任何内容。

sep
the field separator string. Values within each row of x are separated by this string.

分隔符

eol
the character(s) to print at the end of each line (row).
For example, eol = "\r\n" will produce Windows' line endings on a Unix-alike OS,
and eol = "\r" will produce files as expected by Excel:mac 2004.
na
the string to use for missing values in the data.

用于缺失值的字符


dec
the string to use for decimal points in numeric or complex columns:
must be a single character.

数值或者复数型数值列中用于小数点的字符,取值必须为单个字符。

write.table(data,'C:\\Users\\***\\Desktop\\c1.txt',dec=',')

row.names
either a logical value indicating whether the row names of x
are to be written along with x,
or a character vector of row names to be written.

行名
逻辑值,指示x的行名是否要与x一起写入,或者为要写入的行名的字符向量。

row.names=F,不带默认的行名称1,2,3,4


为输出结果定义行名称 row.names=c(‘r1’,‘r2’,‘r3’,‘r4’)

col.names
either a logical value indicating whether the column names of x
are to be written along with x,
or a character vector of column names to be written.
See the section on ‘CSV files’ for the meaning of col.names = NA.

列名
逻辑值,指示x的列名是否要与x一起写入,或者是要写入的列名的字符向量。

write.table(data,'C:\\Users\\***\\Desktop\\c1.txt',col.names=c('学号','性别','数学','英语','语文'))

qmethod
a character string specifying how to deal with
embedded double quote characters when quoting strings.
Must be one of "escape" (default for write.table),
in which case the quote character is escaped in C style by a backslash,
or "double" (default for write.csv and write.csv2),
in which case it is doubled.
You can specify just the initial letter.
fileEncoding
character string: if non-empty declares the encoding to be used on a file (not a connection) so the character data can be re-encoded as they are written.

输出文件编码
字符串:表明输出字符串中的内容编码方式

参数 参数含义 write.table write.csv
x 要输出的数据
file 文件路径
append 是否将输出追加到原文件 ×,不能修改参数为T
quote 对引号的处理
sep 行中字段之间的分隔符 ×,csv以逗号分隔,不能修改参数
eol 尚不清楚
na 缺失值
dec 小数点 ×, csv使用点 . 表示小数点
row.names 行名称
col.names 列名称 ×,不能修改
qmethod 尚不清楚 ×,不能修改
fileEncoding 输出文件编码

Data Output write.table

write.csv()函数--R语言相关推荐

  1. c r语言中rank函数,R语言rank函数详细解析

    R语言rank函数详细解析 发布于 2016-01-04 16:26:04 | 557 次阅读 | 评论: 0 | 来源: PHPERZ R 数据统计分析语言R是用于统计分析.绘图的语言和操作环境.R ...

  2. quantile函数r语言_R中的Quantile()函数-简要指南

    quantile函数r语言 You can generate the sample quantiles using the quantile() function in R. 您可以使用R中的Quan ...

  3. r语言读取C盘的csv文件,R语言开发之CSV文件的读写操作实现

    在R中,我们可以从存储在R环境外部的文件读取数据,还可以将数据写入由操作系统存储和访问的文件.这个csv文件应该存在于当前工作目录中,以方便R可以读取它, 当然,也可以设置自己的目录,并从那里读取文件 ...

  4. r语言 c d生产函数,R语言 函数与模型(12):随机前沿模型SFA

    ______________________________ ______________________________ 查看往期R语言与函数系列 _________________________ ...

  5. matlab 雷达图函数,R语言之可视化(20)ggradar雷达图

    目录 R语言之可视化(20)ggradar雷达图 ======================= ggradar是一个ggplot2函数,主要用于绘制数据分析的雷达图. 它基于Ricardo Bion ...

  6. c语言分组求和函数,R语言 实现data.frame 分组计数、求和等

    df为1个data.frame对象,有stratum和psu两列,这里统计stratum列计数 方法1: cnt = table(df$stratum) 方法2: cnt = tapply(df$ps ...

  7. 1071svm函数 r语言_R语言机器学习之核心包e1071 - 数据分析

    R语言有很多包可以做机器学习(Machine Learning)的任务.机器学习的任务主要有有监督的学习方式和无监督的学习方式. 有监督学习:在正确结果指导下的学习方式,若是正确结果是定性的,属于分类 ...

  8. 自定义函数 | R语言偏相关分析及绘图

    R语言的偏相关分析过程 偏相关分析介绍 阶偏相关分析: 偏相关系数: Pearson相关系数 Spearman相关系数 Kendall等级相关系数 R语言实现偏相关分析 pcor() pcor.tes ...

  9. r 语言c函数,R语言常用函数详解

    R语言对于我们生信人员来讲,再熟悉不过,然而任何一门语言想要学好,必须经过常年的日积月累才可以做到,在这里,我列举R中常用的函数的用法, 供大家学习. 1.序列函数seq 用法: seq(form,t ...

  10. c 语言matrix函数,R语言矩阵matrix函数

    矩阵是元素布置成二维矩形布局的R对象. 它们包含相同原子类型的元素.尽管我们可以创建只包含字符或只逻辑值的矩阵,但是它们没有多大用处.我们使用的是在数学计算中含有数字元素矩阵. 使用 matrix() ...

最新文章

  1. 盘一盘 2021 年程序员们喜欢的网站数据
  2. 50位青年科学家获颁1.5亿大奖!3位大咖这样寄语
  3. DNS主从类型的架设
  4. Python -day 9
  5. JAVA不借助第三个变量实现两个变量交换的思考
  6. 如何使用 EF Core 按周 对数据分组?
  7. Linux下ftp的安装配置
  8. python怎么另起一行继续输入_python如何换行继续输入
  9. linux ssd硬盘做缓存,linux系统中ssd当块设备缓存
  10. [Ext JS 4] 实战之Chart, Column Chart 定制颜色
  11. 机器学习之特征选择方法
  12. 2019年度YC全美路演,来看出色项目的全解析!
  13. 获取国家全部行政区(名称,简称,区划代码)
  14. 如何建立一个网站(我的5年经验谈)
  15. 惊喜,Windows 11 竟然支持运行安卓应用,而且开发者收益 0 抽成,PC 端摸鱼不是梦...
  16. 其他blast使用方法
  17. 非洲勒索软件、僵尸网络攻击有所增加——但在线诈骗仍构成最大威胁
  18. 二叉排序树查找成功和不成功的平均查找长度
  19. 财务自由之路——我的投资史(2)
  20. JRDZ静态中间继电器

热门文章

  1. Improving your productivity in the Visual Studio Editor
  2. Atitit QL查询语言总结 目录 1. QL = Query Language, 是查询语言的简称 1 2. 具体实现 1 2.1. Apcl 流程控制语言 1 2.2. 脚本流程控制 2 2.
  3. Atitit 信息处理设备与历史与趋势 目录 1. It设备简史与艾提拉觉得常见重要的设备 2 2. 第一部分 IT萌芽期(约公元前4000年至1945年) 2 2.1. 苏美尔人的象形文字(约公元
  4. Atitit 模块打包器(module bundler)的概念与使用 目录 1. 解决问题 1 1.1. 多js合并方便性能加载 1 1.2. 静态模块打包 2 1.3. 动态模块打包 2 2. 最
  5. Atitit nosql的概念与attilax的理解 目录 1. 常见的nosql 二、Redis,Memcache,MongoDb的特点 1 HBase 1 2. Nosql的核心nosql 1
  6. Atitit 全屏模式的cs桌面客户端软件gui h5解决方案 Kiosk模式
  7. Atitit.python web环境的配置 attilax 总结
  8. atitit.session的原理以及设计 java php实现的异同
  9. atitit.ajax bp dwr 3.的注解方式配置使用流程总结 VO9o.....
  10. paip.提升安全性-----时间判断