running codes for categories in column

i have one code (fun_r1.R) which i used to run again and again for number of regions in region column.

now i am thinking like creating a list of region and then run the code one by one for all regions in "region"

also i want to create a folder for regions and then save the files in the same folder

    path <- getwd() 
    region<- c("CA","US","UK") # code should run for the variables here one by one
    for (i in region) {  
      folder <- paste0(path)  # here i want a new folder for CA and save the output here
    
    render (codes.r)
    save.output(path)
    }

what should i do for the required proble here

if i is one of the values of region , (at first "CA" for example), then within the curly braces of your loop, some use should be found for i otherwise the loop always is doing the same thing regardless of i

I have updated my question but i am unable to create that code

  path <- getwd() 
    region<- c("CA","US","UK") # code should run for the variables here one by one
    for (i in region) {  
      folder <- file.path(path,i)  

etc ...

dir.create() is a function that can be used to create folders

this is just i was trying to create but unable to think

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.