Skip to contents

Find most recent version of an orderly report. The most recent report is always the most recently run report that has been committed (regardless of the order in which they were committed).

Usage

orderly_latest(
  name = NULL,
  root = NULL,
  locate = TRUE,
  draft = FALSE,
  must_work = TRUE
)

Arguments

name

Name of the report to find; if NULL returns the most recent report across all names

root

The path to an orderly root directory, or NULL (the default) to search for one from the current working directory if locate is TRUE.

locate

Logical, indicating if the configuration should be searched for. If TRUE and config is not given, then orderly looks in the working directory and up through its parents until it finds an orderly_config.yml file.

draft

Should draft reports be used searched? Valid values are logical (TRUE, FALSE) or use the string newer to use draft reports where they are newer than archive reports. For consistency, always and never are equivalent to TRUE and FALSE, respectively.

must_work

Throw an error if no report is found. If FALSE, returns NA_character_.

Value

A character string with the id of the most recent report

See also

orderly_list and orderly_list_archive for listing report names and versions.

Examples

path <- orderly::orderly_example("minimal")
id1 <- orderly::orderly_run("example", root = path, echo = FALSE)
#> [ name       ]  example
#> [ id         ]  20230621-105031-4e29014e
#> [ start      ]  2023-06-21 10:50:31
#> [ data       ]  source => dat: 20 x 2
#> [ end        ]  2023-06-21 10:50:31
#> [ elapsed    ]  Ran report in 0.01550555 secs
#> [ artefact   ]  mygraph.png: 175369b2bcf4115f343c8ad746c0c072
id2 <- orderly::orderly_run("example", root = path, echo = FALSE)
#> [ name       ]  example
#> [ id         ]  20230621-105031-5accb551
#> [ start      ]  2023-06-21 10:50:31
#> [ data       ]  source => dat: 20 x 2
#> [ end        ]  2023-06-21 10:50:31
#> [ elapsed    ]  Ran report in 0.01578426 secs
#> [ artefact   ]  mygraph.png: 175369b2bcf4115f343c8ad746c0c072

# With no reports committed there is no latest report:
orderly::orderly_latest("example", root = path, must_work = FALSE)
#> [1] NA

# Commit the first report and it will be reported as latest:
orderly::orderly_commit(id1, root = path)
#> [ commit     ]  example/20230621-105031-4e29014e
#> [ copy       ]
#> [ import     ]  example:20230621-105031-4e29014e
#> [ success    ]  :)
#> [1] "/tmp/RtmpGRuIRx/file474abcb5dd/archive/example/20230621-105031-4e29014e"
orderly::orderly_latest("example", root = path)
#> [1] "20230621-105031-4e29014e"

# Commit the second report and it will be reported as latest instead:
orderly::orderly_commit(id2, root = path)
#> [ commit     ]  example/20230621-105031-5accb551
#> [ copy       ]
#> [ import     ]  example:20230621-105031-5accb551
#> [ success    ]  :)
#> [1] "/tmp/RtmpGRuIRx/file474abcb5dd/archive/example/20230621-105031-5accb551"
orderly::orderly_latest("example", root = path)
#> [1] "20230621-105031-5accb551"