Adding a column to a data.frame
Posted
by
Susanne Dreisigacker
on Stack Overflow
See other posts from Stack Overflow
or by Susanne Dreisigacker
Published on 2012-04-14T02:39:18Z
Indexed on
2012/04/16
11:29 UTC
Read the original article
Hit count: 211
r
|data.frame
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
© Stack Overflow or respective owner