I am working with a set of documents and need to automate a groupby and subset into new files. I can accomplish this manually but have over 200 documents with approx 45,000 observations in each that result in over 1,000 documents. My idea was for each instance of a unique value within my df to save all values with that unique name to a df with that name. In the following example I would now have 3 dataframes called : ferrari, ford, and audi.
value <- c(1:10)
name <- c("ferrari","ferrari","ferrari","ford","ford","ford","ford","audi","audi","audi")
data <- data.frame(value,name)
uniques <- unique(data$name)
for(file in uniques){
file <- subset(data, data$Name == file)
}
This just results in a df called file with 0 observations. I have also tried the normal for i in length df. Any help is greatly appreciated - I am definitely not used to writing for loops.