my_summary_COunt <- data %>%
count(District_Name,Sex_of_the_participant, sort = TRUE) %>%
pivot_wider( names_from=Sex_of_the_participant, values_from=n )
I have large data set 256385*568 and I want to use the above code but in a loop so I don't have to put y variable i.e Sex_of_the_participant again.
something like this
my_range= 9:50
for (i in my_range) {
my_summary_COunt_[i] <- data %>%
count(District_Name,data[i], sort = TRUE) %>%
pivot_wider( data[i], values_from=n )}
but this is not working