I have a CSV file with two header rows, the first row I want to be the header, but the second row I want to discard. If I do the following command:
data <- read.csv("HK Stocks bbg.csv", header = T, stringsAsFactors = FALSE)
The first row becomes the header and the second row of the file becomes the first row of my data frame:
Xaaaaaaaaa X X.1 Xbbbbbbbbbb X.2 X.3
1 Date PX_LAST NA Date PX_LAST NA
2 31/12/2002 38.855 NA 31/12/2002 19.547 NA
3 02/01/2003 38.664 NA 02/01/2003 19.547 NA
4 03/01/2003 40.386 NA 03/01/2003 19.547 NA
5 06/01/2003 40.386 NA 06/01/2003 19.609 NA
6 07/01/2003 40.195 NA 07/01/2003 19.609 NA
I want to skip this second row of the CSV file and just get
X1.HK.Equity X X.1 X2.HK.Equity X.2 X.3
2 31/12/2002 38.855 NA 31/12/2002 19.547 NA
3 02/01/2003 38.664 NA 02/01/2003 19.547 NA
4 03/01/2003 40.386 NA 03/01/2003 19.547 NA
5 06/01/2003 40.386 NA 06/01/2003 19.609 NA
6 07/01/2003 40.195 NA 07/01/2003 19.609 NA
I tried data <- read.csv("HK Stocks bbg.csv", header = T, stringsAsFactors = FALSE, skip = 1)
but that returns:
Date PX_LAST X Date.1 PX_LAST.1 X.1
1 31/12/2002 38.855 NA 31/12/2002 19.547 NA
2 02/01/2003 38.664 NA 02/01/2003 19.547 NA
3 03/01/2003 40.386 NA 03/01/2003 19.547 NA
4 06/01/2003 40.386 NA 06/01/2003 19.609 NA
5 07/01/2003 40.195 NA 07/01/2003 19.609 NA
6 08/01/2003 40.386 NA 08/01/2003 19.547 NA
The header row comes from the second line of my CSV file, not the first line.
Thank you.