I have some ranking data colected in LimeSurvey. The data look like this:
The X1, X2...X9 is how the item was ranked.
structure(list(id = c(1L, 2L, 3L, 4L, 5L, 7L), X1 = c("Parque Arví",
"Parque Explora", "Jardín Botánico", "Parque Explora", "Parque Arví",
"Parque Arví"), X2 = c("Jardín Botánico", "Jardín Botánico",
"Parque Explora", "Jardín Botánico", "Parques del Río", "Jardín Botánico"
), X3 = c("Parques del Río", "Parque Arví", "Parque natural Cerro Volador",
"Parques del Río", "Jardín Botánico", "Parque de los Pies Descalzos"
), X4 = c("Parque de los Pies Descalzos", "Parque natural Cerro Volador",
"Parque Arví", "Parque Norte", "Parque Llerás", "Parque Explora"
), X5 = c("Parque de la Luz", "Parque Llerás", "Parque Norte",
"Parque natural Cerro Volador", "Parque Norte", "Parque natural Cerro Volador"
), X6 = c("Parque Explora", "Parque de los Pies Descalzos", "Parques del Río",
"Parque de la Luz", "Parque Explora", "Parques del Río"), X7 = c("Parque natural Cerro Volador",
"Parque Norte", "Parque de los Pies Descalzos", "Parque de los Pies Descalzos",
"Parque de la Luz", "Parque de la Luz"), X8 = c("Parque Norte",
"Parques del Río", "Parque de la Luz", "Parque Arví", "Parque de los Pies Descalzos",
"Parque Norte"), X9 = c("Parque Llerás", "Parque de la Luz",
"Parque Llerás", "Parque Llerás", "Parque natural Cerro Volador",
"Parque Llerás")), class = "data.frame", row.names = c(NA, -6L
))
How can I transpose the data cell values in the original dataframe are converted into column names. The transposed dataframe should look like this:
structure(list(id = c(1L, 2L, 3L, 4L, 5L, 7L), Jardín.Botánico = c(2L,
2L, 1L, 2L, 3L, 2L), Parque.Arví = c(1L, 3L, 4L, 8L, 1L, 1L),
Parque.de.la.Luz = c(5L, 9L, 8L, 6L, 7L, 7L), Parque.de.los.Pies.Descalzos = c(4L,
6L, 7L, 7L, 8L, 3L), Parque.Explora = c(6L, 1L, 2L, 1L, 6L,
4L), Parque.Llerás = c(9L, 5L, 9L, 9L, 4L, 9L), Parque.natural.Cerro.Volador = c(7L,
4L, 3L, 5L, 9L, 5L), Parque.Norte = c(8L, 7L, 5L, 4L, 5L,
8L), Parques.del.Río = c(3L, 8L, 6L, 3L, 2L, 6L)), class = "data.frame", row.names = c(NA,
-6L))
I found this answer, but the solution does not show the column names, only V1, V2, V3, etc. Analyzing LimeSurvey ranking data in R