## 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)
vers <- paste("R package version", meta$Version)
author <- as.personList(meta$Author)
url <- sprintf("http://cran.r-project.org/package=%s", meta$Package)

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

citEntry(entry="Article"
		, title = "A flexible R package for nonnegative matrix factorization"
		, author = personList(as.person("Renaud Gaujoux"), as.person("Cathal Seoighe"))		
		, journal = "BMC Bioinformatics"
		, year = 2010
		, volume = 11
		, number = 1
		, pages = 367
		, url = "http://www.biomedcentral.com/1471-2105/11/367"
		, doi = "10.1186/1471-2105-11-367"
		, issn = "1471-2105"
		, note = vers
		, textVersion =
				paste("Renaud Gaujoux, Cathal Seoighe (2010)"
					, "A flexible R package for nonnegative matrix factorization"
					, "BMC Bioinformatics 2010, 11:367"
					, "[http://www.biomedcentral.com/1471-2105/11/367]"
					, sep=". ")
)

citEntry(entry="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):"
)

citEntry(entry="Manual"
		, title = meta$Title
    	, 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:"
)