Can anyone help me on how to read in a huge data frame (33 rows,38 columns and always a header every 39th column starting with # from daily weather 1951-2015) in R. I have following data in a .txt file naming it test2.txt:
# 1950-01-01 00:59:00
1 5 5 5 9
2 3 4 5 2
# 1950-01-02 00:59:00
4 5 4 4 3
9 4 3 3 3
# 1950-01-03 00:59:00
4 2 3 3 3
2 2 2 3 9
I am trying to read it into R, creating an array or a reasonable matrix to do calculations afterwards. I tried using read.csv and scan, but I guess I am completely going the wrong way. Has anyone an idea which command to use.
read.csv("test2.txt", header=FALSE, sep="")
Additionally I want to add names to the columns and rows afterwards, but this can also happen in a second step. Names should be for rows: A,B and for columns C,D,E,F,G, so in the end, the array would look like this, as the names I assume (e.g.# 1950-01-03 00:59:00) would probably be lost.
, , 1
1 5 5 5 9
2 3 4 5 2
, , 2
4 5 4 4 3
9 4 3 3 3
, , 3
4 2 3 3 3
2 2 2 3 9