I have a for loop that i let go through a list (xlist) with a different output for each iteration of the code. When i use print i get the results for each iteration but i am looking for help to get my printout into a format i can further work with.
The code for the loop looks like this:
for (i in 1:381)
{ print(nrow(mydata %>% add_column(f=replace_na(mydata$Date_1,xlist$xlist[i]))%>%
filter(Date_2 %in% (xlist$xlist[i]- ddays(x=7)):xlist$xlist[i]) %>%
filter(Date_3 %in% (xlist$xlist[i]- ddays(x=7)):xlist$xlist[i]) %>%
filter(f<=xlist$xlist[i])))}
ist prints out all iterations but i can not put it into a list or a dataframe. How do i do that?
How about using map() instead of for() to handle the iterations. All of the results will be neatly available in a numeric vector after running, currently loaded in a variable called at in the sample code here: