citHeader("To cite package lidR in publications use both:")

citEntry(entry="Article",
         author = "Jean-Romain Roussel and David Auty and Nicholas C. Coops and Piotr Tompalski and Tristan R.H. Goodbody and Andrew Sánchez Meador and Jean-François Bourdon and Florian de Boissieu and Alexis Achim",
         title = "lidR: An R package for analysis of Airborne Laser Scanning (ALS) data",
         journal = "Remote Sensing of Environment",
         volume = "251",
         pages = "112061",
         year = "2020",
         issn = "0034-4257",
         doi = "10.1016/j.rse.2020.112061",
         url = "https://www.sciencedirect.com/science/article/pii/S0034425720304314",
         textVersion =
           paste("Roussel, J.R., Auty, D., Coops, N. C., Tompalski, P., Goodbody, T. R. H., Sánchez Meador, A., Bourdon, J.F., De Boissieu, F., Achim, A. (2020).",
           "lidR : An R package for analysis of Airborne Laser Scanning (ALS) data.",
           "Remote Sensing of Environment, 251 (August), 112061. <doi:10.1016/j.rse.2020.112061>.")
)

year <- sub(".*(2[[:digit:]]{3})-.*", "\\1", meta$Date, perl = TRUE)
vers <- paste("R package version", meta$Version)
authors <- meta$`Authors@R`
authors <- utils:::.read_authors_at_R_field(authors)
authors <- Filter(function(e) {!(is.null(e$given) && is.null(e$family)) && !is.na(match("aut", e$role))}, authors)
authors <- format(authors, include = c("given", "family"))
authors <- paste(paste(head(authors, -1L), collapse = ", "), tail(authors, 1L), sep = " and ")

citEntry(entry="Manual",
         title = meta$Title,
         author = authors,
         year = year,
         note = vers,
         textVersion =
           paste(authors, " (",
                 year,
                 "). ", meta$Title, ". ",
                 vers, ". https://cran.r-project.org/package=lidR", sep=""),
         url = "https://cran.r-project.org/package=lidR")
