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

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -