I'm somewhat a new user and have been trying to figure out how to repeat
rows a certain number of time based on a variable.  Currently, the number of
rows is not reflective of the number of observations.  To get the number of
observations (n=22 in this case), I have to multiply by the variable
NoRecords for each row.  So, there are actually 7 cases of cancer and 3
cases of HIV in my data, not 2 cases of HIV and 1 case of cancer.  Is there
an easy way to expand my data so that I actually end up with 22 rows instead
of 10?  Specifically, my data currently look like this:

>my data
   AdmitYear Race Age.yrs. Insurance       HIV   Cancer NoRecords
1       1985    A       20              0                  0
0         1
2       1985    A       21              0                  0
0         1
3       1985    A       22              1                  1
0         1
4       1985    A       23              0                  0
0         2
5       1985    A       24              0                  1
0         2
6       1985    A       24              1                  0
0         1
7       1985    A       25              1                  0
0         3
8       1985    A       26              0                  0
0         2
9       1985    A       26              1                  0           1
        7
10      1985    A       27             0                  0
0         2

thanks!
Andy

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to