I need specific files from "global environment" to run some calculations for each file
I have 390 data files with nearly the same structure in the global environment and i need to take 330 specific files. So I ran a for-loop to compare the elements from the global environment with a list that contains the elements names I need to take. For each file I need to transform a factor variable into dummy-coding.
The for-loop is the following:
for(x in t(upc.unique))
{
xName <- paste(x,"csv", sep = ".")
for(y in tmp) #tmp equals the elements of the global environment
{
as.character(tmp)
if (xName == y)
{ as.list(tmp)
assign(tmp[i], paste(tmp[i],"d")<-cbind(tmp[i], model.matrix(~factor(tmp[i]$SALES) - 1)))
}
}
}
"upc.unique" contains the names of the data files I need to pick from the global environment "tmp" is a large list of each element of the "global environment"
My question is if there's a better and faster way to do the task. Im pretty sure that there is a way, but because I am new with R, it is hard for me to find it.