## R >= 2.8.0 passes package metadata to citation().
if( !exists('meta') || is.null(meta) ) meta <- packageDescription("NMF")

year <- sub(".*(2[[:digit:]]{3})-.*", "\\1", meta$Date, perl = TRUE)
vers <- paste("R package version", meta$Version)
author <- c(meta$Author)
url <- sprintf("https://cran.r-project.org/package=%s", meta$Package)

citHeader(sprintf("To cite the package '%s' in publications use:", meta$Package))

bibentry(bibtype="Article"
		, title = "A flexible R package for nonnegative matrix factorization"
		, author = c("Renaud Gaujoux", "Cathal Seoighe")		
		, journal = "BMC Bioinformatics"
		, year = 2010
		, volume = 11
		, number = 1
		, pages = 367
		, url = "https://bmcbioinformatics.biomedcentral.com/articles/10.1186/1471-2105-11-367"
		, doi = "10.1186/1471-2105-11-367"
		, issn = "1471-2105"
		, textVersion =
				paste("Renaud Gaujoux, Cathal Seoighe (2010)"
					, "A flexible R package for nonnegative matrix factorization"
					, "BMC Bioinformatics 2010, 11:367"
					, "[https://bmcbioinformatics.biomedcentral.com/articles/10.1186/1471-2105-11-367]"
					, sep=". ")
)

bibentry(bibtype="Manual"
		, title = vign <- "Using the package NMF"
    	, author = author
    	, publisher = "CRAN"
    	, year = year
    	, note = vers
    	, url = url
    	, textVersion = sprintf("%s (%s). %s. CRAN. %s. [%s]", author, year, vign, vers, url)
    	, header = "Vignette(s):"
)

bibentry(bibtype="Manual"
		, title = "The package NMF: manual pages"
    	, author = author
    	, publisher = "CRAN"
    	, year = year
    	, note = vers
    	, url = url
    	, textVersion = sprintf("%s (%s). %s CRAN. %s. [%s]", author, year, meta$Title, vers, url)
    	, header = "Technical documentation:"
)
