I am trying to move files from one folder to another. I have a data frame called "data", with "from" location, "to" and file name "myfile".
library(foreign) movefile <- function(from, to, myfile){ readfile <- paste(from, myfile, sep = "/") temp <- read.dta(readfile) copyto <- paste(to, myfile, sep = "/") write.dta(temp, copyto) }
When I call the function with the following line of code:
movefile(data$from, data$to, data$myfile)
It copies only the first file. When I try to diagnose a problem by printing various terms inside the function (for example, adding print (copyto) as the last line of the function), it prints for each file specified in the data, which indicates that the function is executed for each line in the data, but it does not actually copy files beyond the first. How can i fix this?
source share