Looping syntax for creating multiple dataframes in R -


trying create loot out of following code works enough:

datelist = c("2016-01-08","2016-01-09","2016-01-10","2016-01-11",          "2016-01-12")  df1 <- get_intraday_data(cookie, what="heart-rate", date=datelist[1]) df2 <- get_intraday_data(cookie, what="heart-rate", date=datelist[2]) df3 <- get_intraday_data(cookie, what="heart-rate", date=datelist[3]) df4 <- get_intraday_data(cookie, what="heart-rate", date=datelist[4]) df5 <- get_intraday_data(cookie, what="heart-rate", date=datelist[5]) 

i've written loop below, substitutes 1-5 [i] within loop, producing integer named i. how can each day own dataframe?

    (i in 1:5){ df[i] <- get_intraday_data(cookie, what="heart-rate", date=datelist[i]) } 

thanks

you try map function in purrr package. it's kinda lapply. i'm not sure if have quite right, maybe work:

purrr::map(1:5, ~ get_intraday_data(cookie, what="heart-rate", date=datelist[.x])) 

Comments