'Transform dataset into sequence set in R

I am an absolute beginner with R, so I'm sorry in advance for this probably simple question...

I have an excel dataset that looks like this:

enter image description here

Now, I need to transfirm this data into a sequence format so that I have the following:

  1. headers for each columns from year 00 to 20 for each of the columns A and D so that it follows this pattern: 00A|00D|01A|01D|02A...|20D where each number represents the year and each letter either column A or column D
  2. ridding out the duplicate ISINs and implement the corresponding year activity (A and/or D) in the appropriate year row columns created in step 1

Based on the above example, I want to end up with this: enter image description here

Is there any way to perform such an operation?

Thank you so much in advance!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source