First ever question on here! Stackoverflow has been an amazing resource so thank you to all who actively contribute.
I need to create a new variable in a column. This variable needs to be the sum of the values of three other variables (in the same column). The problem here, is that I have another column with two years, and need to keep the years. Issue here being the new variable would be duplicated in two different places and this needs to be the case. (Porting to Tableau for visualization of unemployment)
I have summarized using Dplyr to hopefully give you an an idea of the issue I'm facing, and how best to resolve it.Link to Tibble
I need to combine 'Dun Laoghaire Rathdown', 'Dublin City' and 'South Dublin' into one variable called 'Dublin'. These appear in both 2011, and 2016. The three variables being combined need to be removed so that the new variable 'Dublin' appears in their place as one row per census year (i.e - three variables removed per census year, and one variable called 'Dublin' going in their place)
Console output using Dput on my tibble:
structure(list(Census_Year = c(2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2016L, 2016L, 2016L, 2016L, 2016L, 2016L, 2016L, 2016L, 2016L, 2016L, 2016L, 2016L, 2016L, 2016L, 2016L, 2016L, 2016L, 2016L, 2016L, 2016L, 2016L, 2016L, 2016L, 2016L, 2016L, 2016L, 2016L, 2016L, 2016L, 2016L, 2016L), County.and.City = c("Carlow", "Cavan", "Clare", "Cork City", "Cork County", "Dún Laoghaire-Rathdown", "Donegal", "Dublin City", "Fingal", "Galway City", "Galway County", "Kerry", "Kildare", "Kilkenny", "Laois", "Leitrim", "Limerick City and County", "Longford", "Louth", "Mayo", "Meath", "Monaghan", "Offaly", "Roscommon", "Sligo", "South Dublin", "Tipperary", "Waterford City and County", "Westmeath", "Wexford", "Wicklow", "Carlow", "Cavan", "Clare", "Cork City", "Cork County", "Dún Laoghaire-Rathdown", "Donegal", "Dublin City", "Fingal", "Galway City", "Galway County", "Kerry", "Kildare", "Kilkenny", "Laois", "Leitrim", "Limerick City and County", "Longford", "Louth", "Mayo", "Meath", "Monaghan", "Offaly", "Roscommon", "Sligo", "South Dublin", "Tipperary", "Waterford City and County", "Westmeath", "Wexford", "Wicklow"), Total = c(5908L, 7331L, 10542L, 12266L, 28603L, 11071L, 18869L, 51699L, 22640L, 7234L, 15311L, 13519L, 18639L, 8992L, 8260L, 3047L, 18537L, 4562L, 13792L, 11866L, 16292L, 5982L, 8313L, 5856L, 5624L, 26039L, 14996L, 11572L, 8637L, 16170L, 12674L, 4507L, 5413L, 7018L, 8943L, 18287L, 7716L, 12829L, 39200L, 15415L, 5175L, 9938L, 8701L, 12297L, 6044L, 6068L, 2163L, 12935L, 3701L, 10058L, 8591L, 10523L, 3831L, 5744L, 3847L, 4250L, 18265L, 10867L, 8323L, 6666L, 11478L, 8603L)), row.names = c(NA, -62L), groups = structure(list(Census_Year = c(2011L, 2016L), .rows = structure(list(1:31, 32:62), ptype = integer(0), class = c("vctrs_list_of", "vctrs_vctr", "list"))), row.names = 1:2, class = c("tbl_df", "tbl", "data.frame"), .drop = TRUE), class = c("grouped_df", "tbl_df", "tbl", "data.frame"))
Thanks in advance,
Regards, R