- file:open a connection to a file
- gzfile: “.gz” 压缩文件
- bzfile: ".bz"压缩文件
- url:网页链接
con <- file("foo.txt", "r")
data <- read.csv(con)
close(con)
等同于
data <- read.csv("foo.txt")
因此,在上种情况下,不需要用到connection函数读取
读取行时
> con <- gzfile("words.gz")
> x <- readLines(con, 10)
> x
[1] "1080" "10-point" "10th" "11-point"
[5] "12-point" "16-point" "18-point" "1st"
[9] "2" "20-point"
writeLines takes a character vector and writes each element one line at a time to a text file.
读取网页时
## This might take time
con <- url("http://www.jhsph.e