I have a dataframe 'data.frame': 1 obs. of 100 variables, I need to repeat this row 100 times, each time with a varying number of zeros in the first columns of n+1, or as many zeros as the index of the row-1. At the same time I need to drop the last values of the rows so that I end with a 100 by 100 dataframe.
The dataframe looks like this:
# A tibble: 1 x 1
Mass_PM10_evdf$~ $Mass2 $Mass3 $Mass4 $Mass5 $Mass6 $Mass7 $Mass8 $Mass9
<dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 5.48 11.1 11.3 11.4 11.6 11.7 11.9 12.1 12.2
and I made a short example of what I need the output to look like, just using the first 5 columns.
sample$Mass1 $Mass2 $Mass3 $Mass4 $Mass5
<dbl> <dbl> <dbl> <dbl> <dbl>
1 5.49 11.1 11.3 11.4 11.6
2 0 5.49 11.1 11.3 11.4
3 0 0 5.49 11.1 11.3
4 0 0 0 5.49 11.1
5 0 0 0 0 5.49
How can I do this in a more or less automatic way? I appreciate the help.