Moss, Angela (Dudley PCT)
2010-Apr-07 17:08 UTC
[R] Help with manipulation of svytotal output
I have some output from a survey shown below and would like to insert total rows for each category to then be able to use it as a data set for further analysis. Is it possible to do this in R. In this example I would like to insert a row between rows 5 and 6, 10 and 11, 15 and 16, 20 and 21 and put in the sum of the rows 1-5, 6-10, 11-15, 16-20 and to delete row 21 which has NA in it. I would then like to delete all the headings. svyby(~agestrata, ~cbc1+fruitveg4, dudleyls1rake.male,na.rm=TRUE, svytotal, keep.var=FALSE, keep.names=FALSE) cbc1 fruitveg4 statistic.agestrata18-24 statistic.agestrata25-34 statistic.agestrata35-44 statistic.agestrata45-54 1 Quintile 1 - Most deprived At least 5 portions a day 130.31565 535.3994 725.5864 464.61695 2 Quintile 2 At least 5 portions a day 116.25985 971.5924 1072.9432 1289.14396 3 Quintile 3 At least 5 portions a day 119.63090 588.6535 485.7671 681.34475 4 Quintile 4 At least 5 portions a day 233.74271 442.1516 549.4702 1017.50960 5 Quintile 5 - Least deprived At least 5 portions a day 191.65542 258.3255 1035.7763 964.20185 6 Quintile 1 - Most deprived At least 3 portions a day but less than 5 portions a day 1163.65176 812.2817 847.7915 821.97752 7 Quintile 2 At least 3 portions a day but less than 5 portions a day 854.41301 2038.1105 1908.4803 1632.98484 8 Quintile 3 At least 3 portions a day but less than 5 portions a day 350.58857 1186.9437 1580.7324 997.15605 9 Quintile 4 At least 3 portions a day but less than 5 portions a day 635.96420 1299.5061 1807.8647 1607.09527 10 Quintile 5 - Least deprived At least 3 portions a day but less than 5 portions a day 801.78867 1133.7754 1780.5181 1338.63222 11 Quintile 1 - Most deprived At least 1 portion a day but less than 3 portions a day 1080.43401 1781.2609 1567.9033 1651.86604 12 Quintile 2 At least 1 portion a day but less than 3 portions a day 1222.29136 2111.7430 2193.7630 2342.40104 13 Quintile 3 At least 1 portion a day but less than 3 portions a day 747.29574 462.3991 1364.6984 1219.36944 14 Quintile 4 At least 1 portion a day but less than 3 portions a day 673.82467 1561.5540 1523.9977 1261.08650 15 Quintile 5 - Least deprived At least 1 portion a day but less than 3 portions a day 691.33157 753.4532 1197.1077 832.86222 16 Quintile 1 - Most deprived Less than 1 portion a day 1177.65865 1106.4168 1041.1149 663.32088 17 Quintile 2 Less than 1 portion a day 1442.89549 858.8433 860.4825 543.39877 18 Quintile 3 Less than 1 portion a day 482.81678 438.7960 209.4333 219.09875 19 Quintile 4 Less than 1 portion a day 355.95524 602.9579 230.1154 103.97971 20 Quintile 5 - Least deprived Less than 1 portion a day 237.18159 124.9571 272.6678 278.86157 21 Quintile 3 <NA> 54.54834 183.7206 104.6183 71.62796 statistic.agestrata55-64 statistic.agestrata65-74 statistic.agestrata75+ 1 788.16426 285.15923 342.03663 2 1345.66815 835.61670 647.79904 3 778.50509 457.43403 386.32130 4 1480.68186 737.95587 399.37268 5 1242.72517 769.84782 505.91497 6 957.68280 729.33957 283.24008 7 1309.04851 1531.25805 849.31489 8 940.99721 759.60766 536.17955 9 1718.57273 1066.34420 488.20511 10 1480.23054 981.71085 527.65311 11 1048.45233 588.07594 602.18153 12 1666.34520 1423.16681 806.75982 13 799.65987 449.90590 325.59044 14 1075.42891 735.50087 400.61054 15 667.46130 503.03502 257.76220 16 459.15348 149.28894 216.21311 17 240.57459 318.47371 267.37350 18 98.50146 101.61448 48.09493 19 217.09855 55.47692 89.46138 20 246.18142 62.57087 73.32186 21 186.47726 277.25464 386.75818 Many thanks for your help Dr Angela Moss Senior Public Health Intelligence Specialist Dudley PCT St. John's House Union Street Dudley DY2 8PP Tel: 01384 366493 Fax: 01384 366485 [[alternative HTML version deleted]]