Hello.
I am trying to create a yes/no table based on the following data.
I wanted the economic variables as columns- so I would have to make it a wide table first.
Any ideas of how to do this?
r4ds textbook, chapter relating to tidy-data, and pivoting wider :
12 Tidy data | R for Data Science (had.co.nz)
I don't exactly know what you mean by yes/no table. would everything be yes, as if its not in the initial table its not known about, and when rearranging the info in the initial table nothing should be lost... i.e. what would correspond to a 'no' ?
Completely guessing, but are you trying to count the combinations ?
library(tidyverse)
(some_data <- data.frame(
Code=c(letters[1:5],letters[1:3]),
Out.Subind = c(1:5,1:3)
))
# maybe you want to count?
some_data %>% group_by_all() %>% count() %>%
pivot_wider(names_from=c("Code","Out.Subind"),
values_from="n")