Read File in R Line by Line

The R code below reads a file line by line.

path <- "/path/to/the/file"
print(path)
 
conn <- file(path,open="r")
lines <- readLines(conn)
for (i in 1:length(lines)){
   print(lines[i])
}
close(conn)

Leave a Comment