forked from EmilyMarkowitz-NOAA/NMFSReports
-
Notifications
You must be signed in to change notification settings - Fork 0
/
notes.R
152 lines (117 loc) · 4.89 KB
/
notes.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# https://pkgdown.r-lib.org/reference/build_site.html
# Wish list
# Links to figures and tables in text
# https://holtzy.github.io/Pimp-my-rmd/#internal_link
########### Document Package ############
.rs.restartR()
# options(rmarkdown.html_vignette.check_title = FALSE)
Sys.setenv('PATH' = paste0('C:/Program Files/qpdf-10.0.1/bin;', Sys.getenv('PATH')))
library(here)
library(devtools)
library(roxygen2)
devtools::document()
setwd("..")
install("NMFSReports")
3
setwd(here::here())
# devtools::check()
########### Create Documentation GitHub-Pages ############
.rs.restartR()
# devtools::install_github("rstudio/fontawesome", force = T)
# library(fontawesome)
library(here)
library(usethis)
library(pkgdown)
# options(rmarkdown.html_vignette.check_title = FALSE)
# git rm -r --cached .
# pkgdown::build_favicons()
devtools::build_vignettes()
usethis::use_pkgdown(config_file = "./pkgdown/_pkgdown.yml")
pkgdown::build_site(pkg = here::here())
# usethis::use_github_action("pkgdown")
# usethis::use_github_pages(branch = "main", path = "/docs", cname = NA)
# template:
# params:
# bootswatch: sandstone
########### Submit to CRAN ############
# devtools::check() # add the console output to cran-commentes.md
# devtools::check_rhub() # check that your email is 'validated.' You'll need a token emailed to you
# devtools::check_win_devel()
# devtools::release()
##########build a vignette#########
# usethis::use_vignette("A_buildReport-test")
# usethis::use_vignette("ScriptLayout")
# usethis::use_vignette("ExampleRunFile")
# usethis::use_vignette("InitialSetUp")
#########NOTES#########
# bootstrap shiny design
# https://gallery.shinyapps.io/117-shinythemes/
# Guide for checking CMD CHECK()
# https://r-pkgs.org/r-cmd-check.html
# loading qpdf:
# https://stackoverflow.com/questions/41570633/how-to-build-qpdf-on-windows
# https://stackoverflow.com/questions/15035150/r-cmd-check-as-cran-warning
# https://sourceforge.net/projects/qpdf/files/qpdf/10.0.1/
# Sys.setenv('PATH' = paste0('C:/Program Files/qpdf-10.0.1/bin;', Sys.getenv('PATH')))
# Sys.which(Sys.getenv("R_QPDF", "qpdf"))
# Compress Files
# https://stackoverflow.com/questions/10233593/how-to-effectively-deal-with-uncompressed-saves-during-package-check
# save(land, file="./data/sysdata.rda", compress='xz')
# Add a favicon
# https://github.com/r-lib/pkgdown/issues/379
# Licence
# https://stackoverflow.com/questions/56102225/r-devtoolscheck-license-is-not-mentioned-and-other-issues-in-description-file
# Dealing with "no visible binding for global variable '*'"
# https://stackoverflow.com/questions/9439256/how-can-i-handle-r-cmd-check-no-visible-binding-for-global-variable-notes-when
# clean up gitignore
# https://stackoverflow.com/questions/48955103/non-standard-file-directory-found-at-top-level-readme-rmd-persists-even-after
# Make code citable
# https://guides.github.com/activities/citable-code/
# General Reference
# https://github.com/timjmiller/wham/blob/master/DESCRIPTION
# date: "`r format(Sys.Date(), format='%B %d %Y') `"
#https://github.com/r-lib/pkgdown/issues/379
######## OLD STUFF #############
#'Replace the first value, if missing, with the next nearest value.
#'
#' If the first value of the timeseries of this column (c) is 0/NaN/NA. Change the first value (and subsequent 0/NaN/NA values) to the first available non-0/NaN/NA value. Then, used in before with 'ReplaceMid'.
#' @param colnames Names of columns to apply this action to.
#' @param temp Name of dataset to apply this action to.
#' @keywords Replace, First
#' @export
#' @examples
#' ReplaceFirst()
ReplaceFirst <- function(colnames, temp) {
for (c0 in 1:length(colnames)) {
if (temp[1, colnames[c0]] %in% c(0, NA, NaN, NULL)) {
findfirstvalue <-
temp[which(!(temp[, colnames[c0]] %in% c(0, NA, NaN, NULL))),
colnames[c0]][1]
temp[1, colnames[c0]] <- findfirstvalue
}
}
return(temp)
}
#'Replace the first value, if missing, with the next nearest value.
#'
#' If a middle value of the timeseries of this column (c) is 0/NaN/NA. Change the currently 0/NaN/NA value to the previous available non-0/NaN/NA value. Then, used after with 'ReplaceFirst'.
#' @param colnames Names of columns to apply this action to.
#' @param temp Name of dataset to apply this action to.
#' @keywords Replace, Mid, Middle
#' @export
#' @examples
#' ReplaceMid()
ReplaceMid <- function(colnames, temp) {
for (c0 in 1:length(colnames)) {
#If a middle value of the timeseries of this column (c) is 0/NaN/NA
#Change the currently 0/NaN/NA value to the previous available non-0/NaN/NA value
if (sum(temp[, colnames[c0]] %in% c(0, NA, NaN, NULL)) > 0) {
troublenumber <- which(temp[, colnames[c0]] %in% c(0, NA, NaN, NULL))
for (r in 1:length(troublenumber)) {
findlastvalue <- temp[troublenumber[r] - 1, colnames[c0]][1]
temp[troublenumber[r], colnames[c0]] <- findlastvalue
}
}
}
return(temp)
}