r - How to extract the first line from a text file? -
i have text file read this:
file=read.table("file.txt",skip="1",sep="")
the first line of text file contains information file followed observations.
i want extract first line , write out new text file.
to read first line of file, can do:
con <- file("file.txt","r") first_line <- readlines(con,n=1) close(con)
to write out, there many options. here one:
cat(first_line,file="first_line.txt")
Comments
Post a Comment