I have a dataframe in R, which I want to convert to a table using certain variables. The dataset is similar to the following...
Gender | AgeBand | Type of Ilness |
---|---|---|
Male | 0 - 64 | Ilness One |
Male | 0 - 64 | Ilness One |
Male | 0 - 64 | Illness Two |
Male | 65+ | Ilness Three |
Female | 65+ | Ilness Three |
Male | 0 - 64 | Illness Four |
Female | 65+ | Illness Four |
Female | 65+ | Ilness Five |
Female | 0 - 64 | Ilness Five |
Female | 65+ | Illness Two |
And I want it to look like this...
I've had a good look on the web and can't seem to find any code to do this. I've tried using the table function but it doesn't seem appropriate for this. I also want to save the table as it looks into a file so that the rownames become a column. Can anyone help please?