常用的输出函数:cat()
常用的输入函数:scan(),readline(),readLines()
(1) cat()函数
Description
Outputs the objects, concatenating the representations. cat performs much less conversion than print.
Useage
cat(... , file = "", sep = " ", fill = FALSE, labels = NULL,append = FALSE)
参数介绍:
...:输出对象
file:一个文件链接或者文件名,如果不写此参数,表示输出到控制台。
sep:分隔符
append:是否追加,当且仅当参数file是文件名而非链接时,此参数才有效。
例:
> cat(1:10)
1 2 3 4 5 6 7 8 9 10
把一个向量输出到控制台。
> output <- file('output.txt') //建立链接
> class(output) //查看链接属性,是connection
[1] "file" "connection"
> getwd()