R读写文件数据
读文件
read.table(file, header = FALSE, sep = "", quote = "\"'",
dec = ".", numerals = c("allow.loss", "warn.loss", "no.loss"),
row.names, col.names, as.is = !stringsAsFactors,
na.strings = "NA", colClasses = NA, nrows = -1,
skip = 0, check.names = TRUE, fill = !blank.lines.skip,
strip.white = FALSE, blank.lines.skip = TRUE,
comment.char = "#",
allowEscapes = FALSE, flush = FALSE,
stringsAsFactors = default.stringsAsFactors(),
fileEncoding = "", encoding = "unknown", text, skipNul = FALSE)
read.csv(file, header = TRUE, sep = ",", quote = "\"",
dec = ".", fill = TRUE, comment.char = "", ...)
read.csv2(file, header = TRUE, sep = ";", quote = "\"",
dec = ",", fill = TRUE, comment.char = "", ...)
read.delim(file, header = TRUE, sep = "\t", quote = "\"",
dec = ".", fill = TRUE, comment.char = "", ...)
read.delim2(file, header = TRUE, sep = "\t", quote = "\"",
dec = ",", fill = TRUE, comment.char = "", ...)
grubbsTable<-read.csv("C:\\Users\\31210\\Desktop\\grubbsTable.csv",
header = TRUE,
dec = ".",
colClasses = c("integer","double","double","double","double","double"),
nrows = 98,
skip = 0,
fill = TRUE,
strip.white = TRUE,
stringsAsFactors = FALSE,
encoding = "UTF-8",
skipNul = TRUE)
写文件
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(...)
|
参数 |
说明 |
|
append |
追加到文件 |
|
quote |
字符是否用双引号包围 |
|
eol |
每行结尾输出的字符 |
|
row.names |
行名是否写入 |
|
col.names |
列名是否写入 |
> write.csv(grubbsTable,
file = "C:/Users/31210/Documents/123.csv",
row.names = FALSE)
> write.table(grubbsTable,
file = "C:/Users/31210/Documents/123.txt",
append = FALSE,
quote = FALSE,
sep = "\t",
row.names = FALSE)

浙公网安备 33010602011771号