By assigning date_[c], I have 35 "date_c"'s(below code).
for (c in 1:nrow(datetable2)) {
assign(paste("date_",c,sep=""),dt2[which(dt2$Date==datetable2$Date[c]),])
}
Now, I want to change each "date_c"'s rownames to 1:length(date_c). I used the code below but it doesn't work. The program says it can not find "date_[d]". How should I change the "date_[d]" issue in the below loophole?
for (d in 1:nrow(datetable2)){
rownames(date_[d]) <- seq(length=nrow(date_[d]))
}
Get all the
date_c
daatframes in a list, uselapply
to iterate over it and remove the rownames. When we remove the rownames it actually recreates the rownames from1:nrow(data)
.result
would have a list of dataframes with the rownames as we want. It is better to keep data in a list as it is easier to manage them. If you still want the changes to reflect in the original dataframe you can uselist2env
.