R - Readlines

Card Puncher Data Processing

About

Readlines reads lines of a text file and store them in a character vector.

Example

con = gzfile("foo.gz")
x = readLines(con, 10)
close(con)
  • readLines can be useful for reading in lines of webpages
con = url("http://www.gerardnico.com", "r")
x = readLines(con)
head(x)
[1] "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\""           
[2] " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"              
[3] "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\""               
[4] " lang=\"en\" dir=\"ltr\">"                                                  
[5] "<head>"                                                                     
[6] "  <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"







Share this page:
Follow us:
Task Runner