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

Popular posts from this blog

html - Difficulties with background-image property -

visual studio code - What does the isShellCommand property actually do and how should you use it? -

ios - Segue not passing data between ViewControllers -