I'm trying to save a numeric vector that is calculated in a for loop, and then save that into a new column in a dataframe at the end of the for loop.
d.dataframe = NULL
for (i in 1:length(viral_raw)) {
scores <- PWMscoreStartingAt(human.pwm, viral_raw[[i]], starting.at = 1:99)
d.dataframe$i <-scores
}
But right now its overwriting the i'th column everytime
d.dataframe$iline and then addd.dataframe=cbind(d.dataframe,scores)d.dataframe$i <-scoresdoesn't overwrite the ith column, it overwrites the column named "i" in each iteration. See the section "Recursive (list-like) objects" in the help file fromhelp("$"), although this entire help file is worth a careful read.