Adding a column to a data.frame
- by Susanne Dreisigacker
I have the data.frame below. I want to add a column that classifies my data according to column 1 (h_no) in that way that the first series of h_no 1,2,3,4 is class 1, the second series of h_no (1 to 7) is class 2 etc. such as indicated in the last column.
h_no h_freq h_freqsq
1 0.09091 0.008264628 1
2 0.00000 0.000000000 1
3 0.04545 0.002065702 1
4 0.00000 0.000000000 1
1 0.13636 0.018594050 2
2 0.00000 0.000000000 2
3 0.00000 0.000000000 2
4 0.04545 0.002065702 2
5 0.31818 0.101238512 2
6 0.00000 0.000000000 2
7 0.50000 0.250000000 2
1 0.13636 0.018594050 3
2 0.09091 0.008264628 3
3 0.40909 0.167354628 3
4 0.04545 0.002065702 3