Reputation: 509
I have a csv file that looks like:
Point Site Energy Savings (%/yr) Annualized Energy Related Costs ($/yr)
Optimal Point 0 0 1822.880005
Optimal Point 1 14.39999962 1608.069946
Optimal Point 2 20.65999985 1596.76001
Optimal Point 3 26.05999947 1639.98999
Optimal Point 4 34.54999924 1786.359985
Point Site Energy Savings (%/yr) Annualized Energy Related Costs ($/yr)
Reference 0 1822.880005
Iter 1, Pt 1 6.929999828 1818.089966
Iter 1, Pt 2 8.170000076 1863.180054
Iter 1, Pt 3 4.159999847 1845.390015
And I am trying to read it into R to plot the 2nd and 3rd column in a scatterplot, however read.csv is getting confused because of the double header. Any idea how to read it into R skipping the second header?
I would like the following to show in R:
Point Site Energy Savings (%/yr) Annualized Energy Related Costs ($/yr)
Optimal Point 0 0 1822.880005
Optimal Point 1 14.39999962 1608.069946
Optimal Point 2 20.65999985 1596.76001
Optimal Point 3 26.05999947 1639.98999
Reference 0 1822.880005
Iter 1, Pt 1 6.929999828 1818.089966
Iter 1, Pt 2 8.170000076 1863.180054
Iter 1, Pt 3 4.159999847 1845.390015
Upvotes: 0
Views: 1482
Reputation: 15451
I would do something like:
# read in first 5 rows only
a <- read.csv(file, nrows=5, header=TRUE)
# read in the last rows skipping the first 5 row data set
b <- read.csv(file, skip=6, header=TRUE)
rbind(a,b) # put them back together
Upvotes: 2