R code for loop need help

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

See the FAQ: How to do a minimal reproducible example reprex for beginners. Some data is needed to readily answer the question. It doesn't have to be all your data or even your data at all, so long as it behaves the same way. It can even be fake data or from a standard data set.