I have a dataframe (df1) with three columns: Name, Decade and Count. For example:
Name <- c("a","b","c")
Decade <- c(1810,1850,1900)
Count <- c(2,3,1)
df1 <- data.frame(Name,Decade,Count)
print(df1)
Name Decade Count
1 a 1810 2
2 b 1850 3
3 c 1900 1
I wish to create a new dataframe (df2) with columns Name and Decade, with repeating rows of values in df1$Name and df1$Decade by df1$Count. For each repeating row in df2, I wish the df2$Decade to increase by an increment of 10. The first instance of each df2$Name and df2$Decade combination would be equal to df1$Name and df1$Decade.
In the above example, my desired output would be:
> print(df2)
Name Decade
1 a 1810
2 a 1820
3 b 1850
4 b 1860
5 b 1870
6 c 1900
I would love to show my workings so far, but I don't know how to start and have been manually doing it in excel. [hangs head in shame]
Thank you for your time in advance.