Skip specific rows using read.csv in R -


i wish skip 1st , 3rd rows of csv file when importing file data frame in r.

in original file headers on line 2.

using skip argument in read.csv can skip 1st line , set header argument true still have 3rd line original file in data frame.

can suggest how skip multiple specific rows in r, below able cobble together?

can pass vector skip argument specifying exact rows ignore?

prach <- read.csv("rsran104_-_prach_propagation_delay-plmn-day-rsran_ru50ep1_reports_rsran104_xml-2016_08_23-21_33_03__604.csv", header = true, sep = ",", stringsasfactors = false, skip = 1) 

one way using 2 read.csv commands, first 1 reads headers , second 1 data:

headers = read.csv(file, skip = 1, header = f, nrows = 1, as.is = t) df = read.csv(file, skip = 3, header = f) colnames(df)= headers 

i've created following text file test this:

do not read a,b,c previous line headers 1,2,3 4,5,6 

the result is:

> df   b c 1 1 2 3 2 4 5 6 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -