R script to sort and open files

I want the user to determine for each file (csv file) in my folder if this file has to be considered as a type A or a type B file. If the first file listed is a type A file, this file should be moved to an empty A subfolder, or else to a B subfolder, etc. then i want to open the first file in subfolder A, then the second, etc, and i don't want to lose the names of each file... could someone tell me how to do this ? below is what i wrote but i'm really not sure if it is correct and i miss some parts (with question marks)...

fun <- function("../R/") 
{
files <- list.files("../R/")
name <- word(files, 1, 1, sep = "/")
for(i in length(files))
{
cat(name[i], "\n")
ANSWER <- readline("is this a type A file (Y/N) ? ")
  if (substr(ANSWER, 1, 1) == "yes")
  file.move("("../R/??", "../R/A")
  else 
  file.move("("../R/??", "../R/B")
}
read.csv("../R/A/??.csv", sep=";", dec=",")
...
}

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