So I am trying to split one data frame into multiple. I currently have:
y <- data.frame(day=c('1','1','2','2'),amount=c(1,2,3,4))
for(i in 1:2){
i <- as.character(i)
for(j in 1:4){
if (grep(i, y$day, value = TRUE) > 0){
assign(paste0('df', i)) <- rbind(assign(paste0('df', i)),y[j])
}
}
}
It then gives me an error and warning saying:
Error in assign(paste0("df", i)) :
argument "value" is missing, with no default
In addition:
Warning message:
In if (grep(i, y$day, value = TRUE) > 0) { :the condition has length > 1 and only the first element will be used
I can't seem to find what value is supposed to be or where to put it.