diff --git a/.Rbuildignore b/.Rbuildignore index 33cc41e..148fac0 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -3,3 +3,6 @@ ^_pkgdown\.yml$ ^docs$ ^pkgdown$ +^\.github$ +^LICENSE\.md$ +inst/TextAnalysis diff --git a/DESCRIPTION b/DESCRIPTION index b002ddb..62a0d0c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -5,14 +5,17 @@ Authors@R: person("First", "Last", , "first.last@example.com", role = c("aut", "cre"), comment = c(ORCID = "YOUR-ORCID-ID")) Description: What the package does (one paragraph). -License: `use_mit_license()`, `use_gpl3_license()` or friends to pick a - license +License: GPL (>= 3) | file LICENSE Encoding: UTF-8 Roxygen: list(markdown = TRUE) RoxygenNote: 7.2.3 Imports: mvbutils, - tools + tools, + hexSticker, + jsonlite, + jsonvalidate, + shiny Suggests: testthat (>= 3.0.0) Config/testthat/edition: 3 diff --git a/NAMESPACE b/NAMESPACE index bd3aacd..c2d5178 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -9,3 +9,8 @@ export(read_in) export(shiny_dd) export(validate_Rd) import(tools) +importFrom(hexSticker,sticker) +importFrom(jsonlite,fromJSON) +importFrom(jsonlite,toJSON) +importFrom(jsonvalidate,json_validate) +importFrom(shiny,runApp) diff --git a/R/add_object.R b/R/add_object.R index c96ad09..d5f24e5 100644 --- a/R/add_object.R +++ b/R/add_object.R @@ -3,6 +3,8 @@ #' @param input_list A list of fields corresponding to entries. Must include #' \code{name,description,Examples, Units, Rationale, Alternatives, Range of possible values} #' @return An R list in the JSON format which includes the new term. +#' @importFrom jsonlite fromJSON toJSON +#' @importFrom jsonvalidate json_validate #' @export add_object <- function(input_list) { json_obj <- jsonlite::fromJSON(system.file("extdata","top20.json", package = "stockassessmentdictionary")) diff --git a/R/make_hex.R b/R/make_hex.R index 1c0b046..151eb95 100644 --- a/R/make_hex.R +++ b/R/make_hex.R @@ -1,3 +1,7 @@ +#' Create a hexagonal sticker for the 'fishdictionary' package. +#' +#' @importFrom hexSticker sticker +#' @return The function does not return any value but creates a hexagonal sticker image. make_hex <- function(){ hexSticker::sticker(paste0("./static/pictures/", c("nounbook.png","nounfish.png")), package="fishdictionary", p_size=20, s_x=c(1,1), s_y=c(.4,.9), diff --git a/R/shiny_dd.r b/R/shiny_dd.r index bfecbce..705e538 100644 --- a/R/shiny_dd.r +++ b/R/shiny_dd.r @@ -1,6 +1,7 @@ #' Run the data dictionary app #' #' Run the data dictionary app +#' @importFrom shiny runApp #' @export #' @param browse Logical. Use browser for running Shiny app. #' @examples diff --git a/R/validate_Rd.R b/R/validate_Rd.R index f771ea5..ee815ae 100644 --- a/R/validate_Rd.R +++ b/R/validate_Rd.R @@ -13,7 +13,7 @@ validate_Rd <- function(Rd_file) { if (is.null(Rd_file)) stop("Please provide the path to the R documentation (Rd) file.") Rd <- tools::parse_Rd(Rd_file) - tags <- tools:::RdTags(Rd) + tags <- lapply(Rd, attr, "Rd_tag") # Validate name name <- Rd[[which(tags == "\\name")]] diff --git a/TextAnalysis/top10_analysis.R b/inst/TextAnalysis/top10_analysis.R similarity index 89% rename from TextAnalysis/top10_analysis.R rename to inst/TextAnalysis/top10_analysis.R index 26aa218..c49d4cf 100644 --- a/TextAnalysis/top10_analysis.R +++ b/inst/TextAnalysis/top10_analysis.R @@ -214,9 +214,9 @@ proportion_database <- rbind( ) proportion_database[nrow(proportion_database), "ID"] <- "Sum" -write.csv(frequency_database, file=here::here("TextAnalysis", "top10_frequency.csv"), row.names=FALSE) -write.csv(presence_database, file=here::here("TextAnalysis", "top10_presence.csv"), row.names=FALSE) -write.csv(proportion_database, file=here::here("TextAnalysis", "top10_proportion.csv"), row.names=FALSE) +write.csv(frequency_database, file=here::here("inst", "TextAnalysis", "top10_frequency.csv"), row.names=FALSE) +write.csv(presence_database, file=here::here("inst", "TextAnalysis", "top10_presence.csv"), row.names=FALSE) +write.csv(proportion_database, file=here::here("inst","TextAnalysis", "top10_proportion.csv"), row.names=FALSE) # Upload xlsx to Google Drive authorize_GoogleDrive <- FALSE @@ -227,9 +227,9 @@ if (authorize_GoogleDrive) { } # Plot results ------------------------------------------------------------ -frequency_database <- read.csv(file=here::here("TextAnalysis", "top10_frequency.csv")) -presence_database<-read.csv(file=here::here("TextAnalysis", "top10_presence.csv")) -proportion_database<-read.csv(file=here::here("TextAnalysis", "top10_proportion.csv")) +frequency_database <- read.csv(file=here::here("inst", "TextAnalysis", "top10_frequency.csv")) +presence_database<-read.csv(file=here::here("inst", "TextAnalysis", "top10_presence.csv")) +proportion_database<-read.csv(file=here::here("inst", "TextAnalysis", "top10_proportion.csv")) colnames(presence_database) <- col_name data_reshape <- reshape2::melt( @@ -244,7 +244,7 @@ sum_by_group <- aggregate(value ~ keyword+keyword_id+group+Source, data = data_m sum_by_group <- sum_by_group[order(sum_by_group$keyword_id),] group <- unique(sum_by_group$group) -jpeg(filename = here::here("TextAnalysis", "top10_barplot_sum.jpg"), width=200, height=150, units="mm", res=1200) +jpeg(filename = here::here("inst", "TextAnalysis", "top10_barplot_sum.jpg"), width=200, height=150, units="mm", res=1200) ggplot(sum_by_group, aes(fill=Source, y=value, x=keyword_id)) + geom_bar(position="dodge", stat="identity") + facet_wrap(~group, scales = "free_x") + @@ -260,7 +260,7 @@ mean_by_group <- aggregate(value ~ keyword+keyword_id+group+Source, data = data_ mean_by_group <- mean_by_group[order(mean_by_group$keyword_id),] group <- unique(mean_by_group$group) -jpeg(filename = here::here("TextAnalysis", "top10_barplot_mean.jpg"), width=200, height=150, units="mm", res=1200) +jpeg(filename = here::here("inst", "TextAnalysis", "top10_barplot_mean.jpg"), width=200, height=150, units="mm", res=1200) ggplot(mean_by_group, aes(fill=Source, y=value*100, x=keyword_id)) + geom_bar(position="dodge", stat="identity") + facet_wrap(~group, scales = "free_x") + diff --git a/TextAnalysis/top10_barplot_mean.jpg b/inst/TextAnalysis/top10_barplot_mean.jpg similarity index 100% rename from TextAnalysis/top10_barplot_mean.jpg rename to inst/TextAnalysis/top10_barplot_mean.jpg diff --git a/TextAnalysis/top10_barplot_sum.jpg b/inst/TextAnalysis/top10_barplot_sum.jpg similarity index 100% rename from TextAnalysis/top10_barplot_sum.jpg rename to inst/TextAnalysis/top10_barplot_sum.jpg diff --git a/TextAnalysis/top10_frequency.csv b/inst/TextAnalysis/top10_frequency.csv similarity index 100% rename from TextAnalysis/top10_frequency.csv rename to inst/TextAnalysis/top10_frequency.csv diff --git a/TextAnalysis/top10_presence.csv b/inst/TextAnalysis/top10_presence.csv similarity index 100% rename from TextAnalysis/top10_presence.csv rename to inst/TextAnalysis/top10_presence.csv diff --git a/TextAnalysis/top10_proportion.csv b/inst/TextAnalysis/top10_proportion.csv similarity index 100% rename from TextAnalysis/top10_proportion.csv rename to inst/TextAnalysis/top10_proportion.csv diff --git a/TextAnalysis/top20_analysis.R b/inst/TextAnalysis/top20_analysis.R similarity index 88% rename from TextAnalysis/top20_analysis.R rename to inst/TextAnalysis/top20_analysis.R index eb2a6c8..43cb3d1 100644 --- a/TextAnalysis/top20_analysis.R +++ b/inst/TextAnalysis/top20_analysis.R @@ -223,9 +223,9 @@ for (org in seq_along(subfolder_info)){ ) proportion_database[nrow(proportion_database), "ID"] <- "Sum" - write.csv(frequency_database, file=here::here("TextAnalysis", paste0("top20_frequency_", names(subfolder_info)[org], ".csv")), row.names=FALSE) - write.csv(presence_database, file=here::here("TextAnalysis", paste0("top20_presence_", names(subfolder_info)[org], ".csv")), row.names=FALSE) - write.csv(proportion_database, file=here::here("TextAnalysis", paste0("top20_proportion_", names(subfolder_info)[org], ".csv")), row.names=FALSE) + write.csv(frequency_database, file=here::here("inst", "TextAnalysis", paste0("top20_frequency_", names(subfolder_info)[org], ".csv")), row.names=FALSE) + write.csv(presence_database, file=here::here("inst", "TextAnalysis", paste0("top20_presence_", names(subfolder_info)[org], ".csv")), row.names=FALSE) + write.csv(proportion_database, file=here::here("inst", "TextAnalysis", paste0("top20_proportion_", names(subfolder_info)[org], ".csv")), row.names=FALSE) # Upload xlsx to Google Drive if (authorize_GoogleDrive) { # Google Drive folder id @@ -234,9 +234,9 @@ for (org in seq_along(subfolder_info)){ } # Plot results ------------------------------------------------------------ - frequency_database <- read.csv(file=here::here("TextAnalysis", paste0("top20_frequency_", names(subfolder_info)[org], ".csv"))) - presence_database<-read.csv(file=here::here("TextAnalysis", paste0("top20_presence_", names(subfolder_info)[org], ".csv"))) - proportion_database<-read.csv(file=here::here("TextAnalysis", paste0("top20_proportion_", names(subfolder_info)[org], ".csv"))) + frequency_database <- read.csv(file=here::here("inst", "TextAnalysis", paste0("top20_frequency_", names(subfolder_info)[org], ".csv"))) + presence_database<-read.csv(file=here::here("inst", "TextAnalysis", paste0("top20_presence_", names(subfolder_info)[org], ".csv"))) + proportion_database<-read.csv(file=here::here("inst", "TextAnalysis", paste0("top20_proportion_", names(subfolder_info)[org], ".csv"))) word_frequency <- as.matrix(frequency_database[frequency_database$ID == "Sum", 4:ncol(frequency_database)]) word_presence <- as.matrix(presence_database[presence_database$ID == "Sum", 4:ncol(presence_database)]) @@ -266,7 +266,7 @@ for (org in seq_along(subfolder_info)){ ) # barplot - jpeg(filename = here::here("TextAnalysis", paste0("top20_barplot_", names(subfolder_info)[org], ".jpg")), width = 200, height = 120, units = "mm", res = 1200) + jpeg(filename = here::here("inst", "TextAnalysis", paste0("top20_barplot_", names(subfolder_info)[org], ".jpg")), width = 200, height = 120, units = "mm", res = 1200) par(mar = c(6, 4, 1, 1), mfrow = c(3, 1)) frequency_barplot <- barplot(height = word_frequency, xaxt = "n", ylab = "Frequency") text(frequency_barplot - 0.25, par("usr")[3] - 0.25, xlabels, xpd = TRUE, srt = 40, adj = 1, cex = 0.8) @@ -280,14 +280,14 @@ for (org in seq_along(subfolder_info)){ dev.off() - jpeg(filename = here::here("TextAnalysis", paste0("top20_presence_", names(subfolder_info)[org], ".jpg")), width = 200, height = 120, units = "mm", res = 1200) + jpeg(filename = here::here("inst", "TextAnalysis", paste0("top20_presence_", names(subfolder_info)[org], ".jpg")), width = 200, height = 120, units = "mm", res = 1200) par(mar = c(6, 4, 1, 1), mfrow = c(1, 1)) presence_barplot <- barplot(height = word_presence, xaxt = "n", ylab = "Frequency") # range: 26-83, median:68 text(presence_barplot - 0.25, par("usr")[3] - 0.25, xlabels, xpd = TRUE, srt = 40, adj = 1, cex = 0.7) dev.off() # wordcloud figure - jpeg(filename = here::here("TextAnalysis", paste0("top20_wordcloud_", names(subfolder_info)[org], ".jpg")), width = 200, height = 200, units = "mm", res = 1200) + jpeg(filename = here::here("inst", "TextAnalysis", paste0("top20_wordcloud_", names(subfolder_info)[org], ".jpg")), width = 200, height = 200, units = "mm", res = 1200) par(mar = c(1, 1, 1, 1), mfrow = c(1, 1)) wordcloud( words = xlabels, freq = word_presence, rot.per = 0.35, diff --git a/TextAnalysis/top20_barplot_All.jpg b/inst/TextAnalysis/top20_barplot_All.jpg similarity index 100% rename from TextAnalysis/top20_barplot_All.jpg rename to inst/TextAnalysis/top20_barplot_All.jpg diff --git a/TextAnalysis/top20_barplot_Australia.jpg b/inst/TextAnalysis/top20_barplot_Australia.jpg similarity index 100% rename from TextAnalysis/top20_barplot_Australia.jpg rename to inst/TextAnalysis/top20_barplot_Australia.jpg diff --git a/TextAnalysis/top20_barplot_ICES.jpg b/inst/TextAnalysis/top20_barplot_ICES.jpg similarity index 100% rename from TextAnalysis/top20_barplot_ICES.jpg rename to inst/TextAnalysis/top20_barplot_ICES.jpg diff --git a/TextAnalysis/top20_barplot_NOAA.jpg b/inst/TextAnalysis/top20_barplot_NOAA.jpg similarity index 100% rename from TextAnalysis/top20_barplot_NOAA.jpg rename to inst/TextAnalysis/top20_barplot_NOAA.jpg diff --git a/TextAnalysis/top20_frequency_All.csv b/inst/TextAnalysis/top20_frequency_All.csv similarity index 100% rename from TextAnalysis/top20_frequency_All.csv rename to inst/TextAnalysis/top20_frequency_All.csv diff --git a/TextAnalysis/top20_frequency_Australia.csv b/inst/TextAnalysis/top20_frequency_Australia.csv similarity index 100% rename from TextAnalysis/top20_frequency_Australia.csv rename to inst/TextAnalysis/top20_frequency_Australia.csv diff --git a/TextAnalysis/top20_frequency_ICES.csv b/inst/TextAnalysis/top20_frequency_ICES.csv similarity index 100% rename from TextAnalysis/top20_frequency_ICES.csv rename to inst/TextAnalysis/top20_frequency_ICES.csv diff --git a/TextAnalysis/top20_frequency_NOAA.csv b/inst/TextAnalysis/top20_frequency_NOAA.csv similarity index 100% rename from TextAnalysis/top20_frequency_NOAA.csv rename to inst/TextAnalysis/top20_frequency_NOAA.csv diff --git a/TextAnalysis/top20_presence_All.csv b/inst/TextAnalysis/top20_presence_All.csv similarity index 100% rename from TextAnalysis/top20_presence_All.csv rename to inst/TextAnalysis/top20_presence_All.csv diff --git a/TextAnalysis/top20_presence_All.jpg b/inst/TextAnalysis/top20_presence_All.jpg similarity index 100% rename from TextAnalysis/top20_presence_All.jpg rename to inst/TextAnalysis/top20_presence_All.jpg diff --git a/TextAnalysis/top20_presence_Australia.csv b/inst/TextAnalysis/top20_presence_Australia.csv similarity index 100% rename from TextAnalysis/top20_presence_Australia.csv rename to inst/TextAnalysis/top20_presence_Australia.csv diff --git a/TextAnalysis/top20_presence_Australia.jpg b/inst/TextAnalysis/top20_presence_Australia.jpg similarity index 100% rename from TextAnalysis/top20_presence_Australia.jpg rename to inst/TextAnalysis/top20_presence_Australia.jpg diff --git a/TextAnalysis/top20_presence_ICES.csv b/inst/TextAnalysis/top20_presence_ICES.csv similarity index 100% rename from TextAnalysis/top20_presence_ICES.csv rename to inst/TextAnalysis/top20_presence_ICES.csv diff --git a/TextAnalysis/top20_presence_ICES.jpg b/inst/TextAnalysis/top20_presence_ICES.jpg similarity index 100% rename from TextAnalysis/top20_presence_ICES.jpg rename to inst/TextAnalysis/top20_presence_ICES.jpg diff --git a/TextAnalysis/top20_presence_NOAA.csv b/inst/TextAnalysis/top20_presence_NOAA.csv similarity index 100% rename from TextAnalysis/top20_presence_NOAA.csv rename to inst/TextAnalysis/top20_presence_NOAA.csv diff --git a/TextAnalysis/top20_presence_NOAA.jpg b/inst/TextAnalysis/top20_presence_NOAA.jpg similarity index 100% rename from TextAnalysis/top20_presence_NOAA.jpg rename to inst/TextAnalysis/top20_presence_NOAA.jpg diff --git a/TextAnalysis/top20_proportion_All.csv b/inst/TextAnalysis/top20_proportion_All.csv similarity index 100% rename from TextAnalysis/top20_proportion_All.csv rename to inst/TextAnalysis/top20_proportion_All.csv diff --git a/TextAnalysis/top20_proportion_Australia.csv b/inst/TextAnalysis/top20_proportion_Australia.csv similarity index 100% rename from TextAnalysis/top20_proportion_Australia.csv rename to inst/TextAnalysis/top20_proportion_Australia.csv diff --git a/TextAnalysis/top20_proportion_ICES.csv b/inst/TextAnalysis/top20_proportion_ICES.csv similarity index 100% rename from TextAnalysis/top20_proportion_ICES.csv rename to inst/TextAnalysis/top20_proportion_ICES.csv diff --git a/TextAnalysis/top20_proportion_NOAA.csv b/inst/TextAnalysis/top20_proportion_NOAA.csv similarity index 100% rename from TextAnalysis/top20_proportion_NOAA.csv rename to inst/TextAnalysis/top20_proportion_NOAA.csv diff --git a/TextAnalysis/top20_wordcloud_All.jpg b/inst/TextAnalysis/top20_wordcloud_All.jpg similarity index 100% rename from TextAnalysis/top20_wordcloud_All.jpg rename to inst/TextAnalysis/top20_wordcloud_All.jpg diff --git a/TextAnalysis/top20_wordcloud_Australia.jpg b/inst/TextAnalysis/top20_wordcloud_Australia.jpg similarity index 100% rename from TextAnalysis/top20_wordcloud_Australia.jpg rename to inst/TextAnalysis/top20_wordcloud_Australia.jpg diff --git a/TextAnalysis/top20_wordcloud_ICES.jpg b/inst/TextAnalysis/top20_wordcloud_ICES.jpg similarity index 100% rename from TextAnalysis/top20_wordcloud_ICES.jpg rename to inst/TextAnalysis/top20_wordcloud_ICES.jpg diff --git a/TextAnalysis/top20_wordcloud_NOAA.jpg b/inst/TextAnalysis/top20_wordcloud_NOAA.jpg similarity index 100% rename from TextAnalysis/top20_wordcloud_NOAA.jpg rename to inst/TextAnalysis/top20_wordcloud_NOAA.jpg diff --git a/TextAnalysis/tree.txt b/inst/TextAnalysis/tree.txt similarity index 100% rename from TextAnalysis/tree.txt rename to inst/TextAnalysis/tree.txt diff --git a/emltest.R b/inst/examples/emltest.R similarity index 100% rename from emltest.R rename to inst/examples/emltest.R diff --git a/example.R b/inst/examples/example.R similarity index 100% rename from example.R rename to inst/examples/example.R diff --git a/test.R b/inst/examples/test.R similarity index 100% rename from test.R rename to inst/examples/test.R diff --git a/text_mining.R b/inst/examples/text_mining.R similarity index 100% rename from text_mining.R rename to inst/examples/text_mining.R diff --git a/man/Catch.Rd b/man/Catch.Rd index c093698..8d8942c 100644 --- a/man/Catch.Rd +++ b/man/Catch.Rd @@ -10,7 +10,7 @@ \item{Rationale}{Landings and catch are sometimes thought to be interchangeable but they are not given that catch can also include bycatch or unwanted catch.} -\item{Alternatives}{total mortality} +\item{Alternatives}{total mortality, harvest, total removals} \item{Range of possible values}{0--Inf} \item{Units}{mt, numbers} } diff --git a/man/make_hex.Rd b/man/make_hex.Rd new file mode 100644 index 0000000..2ce2ee1 --- /dev/null +++ b/man/make_hex.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/make_hex.R +\name{make_hex} +\alias{make_hex} +\title{Create a hexagonal sticker for the 'fishdictionary' package.} +\usage{ +make_hex() +} +\value{ +The function does not return any value but creates a hexagonal sticker image. +} +\description{ +Create a hexagonal sticker for the 'fishdictionary' package. +} diff --git a/_pkgdown.yml b/pkgdown/_pkgdown.yml similarity index 98% rename from _pkgdown.yml rename to pkgdown/_pkgdown.yml index 8516f37..75045bc 100644 --- a/_pkgdown.yml +++ b/pkgdown/_pkgdown.yml @@ -33,6 +33,7 @@ reference: - read_in - shiny_dd - validate_Rd + - make_hex navbar: diff --git a/extra.css b/pkgdown/extra.css similarity index 100% rename from extra.css rename to pkgdown/extra.css