Looping over a command

Hi everyone,

I have four periods: "1986-01", "1987-01", "1988-01", "1989-01"

I want to make a dataset where each of the following calculations gather in one dataframe:

library("PriceIndices")

tornqvist(df, start="1986-01", end="1986-01", interval = FALSE)
tornqvist(df, start="1986-01", end="1987-01", interval = FALSE)
tornqvist(df, start="1986-01", end="1988-01", interval = FALSE)
tornqvist(df, start="1986-01", end="1989-01", interval = FALSE)
tornqvist(df, start="1987-01", end="1986-01", interval = FALSE)

etc.

Is it possible to do this in a FOR-loop so I can get a more compact code?

Thank you in advance.

If the output of that function is a dataframe or it can be coerced to one, you can use purrr::map_dfr()

If you need more specific help, please provide a proper REPRoducible EXample (reprex) illustrating your issue.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.