Skip to content
Prev 15763 / 63461 Next

documentation for 'open': some clarification?

Here is an example:

# read and print first 10 lines one by one
# the next two lines could be collapsed into con <- file("myfile", r)
con <- file("myfile") 
open(con) 
for(i in 1:10) print(readLines(con, n=1))
close(con) 

Also its possible that you may not need open.  For example,
one can just read it all in at once like this:

mylines <- readLines("myfile")
# and now mylines[1] is the first line, etc.  

# or
my.numbers <- scan("myfile")

# or
my.table <- read.table("myfile")
On 4/14/05, Na Li <nali@umn.edu> wrote: