Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
^_pkgdown\.yml$
^docs$
^pkgdown$
^\.github$
^LICENSE\.md$
inst/TextAnalysis
9 changes: 6 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 2 additions & 0 deletions R/add_object.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
4 changes: 4 additions & 0 deletions R/make_hex.R
Original file line number Diff line number Diff line change
@@ -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),
Expand Down
1 change: 1 addition & 0 deletions R/shiny_dd.r
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion R/validate_Rd.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand All @@ -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") +
Expand All @@ -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") +
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)])
Expand Down Expand Up @@ -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)
Expand All @@ -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,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion man/Catch.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions man/make_hex.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions _pkgdown.yml → pkgdown/_pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ reference:
- read_in
- shiny_dd
- validate_Rd
- make_hex


navbar:
Expand Down
File renamed without changes.