I am doing analysis where a set of cross tabs have to be generated for a large set of distributors. The data is at a customer level and each customer is mapped to a distributor. Since the number of distributors are large, I am trying to automate the process.
I am getting stuck at dynamically creating data frames based on the distributor ID
Here is what I am trying:
for (i in 1:length(DiD)){ #vector comprising list of distributors
paste("use",DiD[[1]],sep="_") <- subset(master table, Field1=="NA"& Field2=="valid" & Field3==as.character(DiD[[1]]))
}
Additional Info:
DiD[[1]] = 1234
Desired output:
A data frame use_1234
which contains the master data subset by Field1
, Field2
and by DiD=1234
Errors Thrown:
Facing issues with the paste part as well with specifying Field3
as DiD[[1]]
Error in eval(expr, envir, enclos) :
dims [product 1] do not match the length of object [529]
I hope that I've provided sufficient information. Thanks a ton!
PS: Apologize if the questions has been answered in the forum, I could not find it.