Skip to content

Commit

Permalink
reoganize files
Browse files Browse the repository at this point in the history
  • Loading branch information
Bai-Li-NOAA committed Oct 19, 2023
1 parent 15dc778 commit 102aa9d
Show file tree
Hide file tree
Showing 38 changed files with 18 additions and 17 deletions.
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
File renamed without changes.
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.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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.

0 comments on commit 102aa9d

Please sign in to comment.