-2

I have an excel file with daily data of temperature from 1903-2018. I would like to re-organize these data. For example the data begins in 1903 and you can see in the first attached file that 2 columns are shown : 1st: the month with daily (1 to 31) and 2nd(Temperature; TAM). I want to make 12 columns for the months for each year (2nd attached file). Its easy to do by hand, but it goes from 1903 to 2018...

So it would be a hard thing to do by hand. Can someone help me to code this (in R)?

attached1 attached2

enter image description here enter image description here

Tung
  • 26,371
  • 7
  • 91
  • 115
Frank
  • 1
  • 1
  • 3
    Hi and welcome to SO. I can see from your public profile that you have not yet taken the [tour](https://stackoverflow.com/tour). I suggest you do so. Afterward, you can come back and [edit](https://stackoverflow.com/posts/52338981/edit) your question to let us know what you've tried so far -- it will save everyone (including you) a lot of time – cybernetic.nomad Sep 14 '18 at 20:57
  • 2
    Please share sample of your data using `dput()` (not `str` or `head` or picture/screenshot) so others can help. See more here https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example?rq=1 – Tung Sep 15 '18 at 00:49

1 Answers1

0

I don't know the code you would use, but I can think of an algorithm:

  1. Go down column B until you see keyword "TAM"
  2. Set variable col to 1
  3. After seeing "TAM", increment variable col by 1
  4. Print all numbers in list under "TAM" to column # col until you don't see a proper date for it in the A column
  5. goto 3 until out of data
Avionix
  • 47
  • 8