Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
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
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export(TADA_HarmonizeSynonyms)
export(TADA_Histogram)
export(TADA_IDCensoredData)
export(TADA_IDDepthProfiles)
export(TADA_InsertBreaks)
export(TADA_JoinWQPProfiles)
export(TADA_MakeSpatial)
export(TADA_OrderCols)
Expand Down
12 changes: 6 additions & 6 deletions R/DepthProfile.R
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ TADA_DepthProfilePlot <- function(.data,

# title for three characteristics
if (length(groups) == 3) {
title <- TADA_InsertBreaks(
title <- stringr::str_wrap(
paste0(
param1$TADA.CharacteristicName[1],
"; ",
Expand All @@ -1052,13 +1052,13 @@ TADA_DepthProfilePlot <- function(.data,
" on ",
format(as.Date(plot.data$ActivityStartDate[1]), "%B %d, %Y")
),
len = 50
width = 50
)
}

# title for two characteristics
if (length(groups) == 2) {
title <- TADA_InsertBreaks(
title <- stringr::str_wrap(
paste0(
param1$TADA.CharacteristicName[1],
" and ",
Expand All @@ -1069,13 +1069,13 @@ TADA_DepthProfilePlot <- function(.data,
" on ",
format(as.Date(plot.data$ActivityStartDate[1]), "%B %d, %Y")
),
len = 50
width = 50
)
}

# title for one characteristic
if (length(groups) == 1) {
title <- TADA_InsertBreaks(
title <- stringr::str_wrap(
paste0(
param1$TADA.CharacteristicName[1],
" for ",
Expand All @@ -1084,7 +1084,7 @@ TADA_DepthProfilePlot <- function(.data,
" on ",
format(as.Date(plot.data$ActivityStartDate[1]), "%B %d, %Y")
),
len = 50
width = 50
)
}

Expand Down
10 changes: 5 additions & 5 deletions R/Figures.R
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ TADA_FieldValuesPie <- function(.data, field = "null", characteristicName = "nul
dat2$Legend <- paste0(dat2$Value, " - ", dat2$Count, " results")
dat <- dat %>%
dplyr::rowwise() %>%
dplyr::mutate(Legend = TADA_InsertBreaks(Legend))
dplyr::mutate(Legend = stringr::str_wrap(Legend, width = 50))

# Only apply the all others category if there are greater than 12 categories to display.
if (dat2$Count != 0) {
Expand Down Expand Up @@ -1019,14 +1019,14 @@ TADA_TwoCharacteristicScatterplot <- function(.data, id_cols = "TADA.ComparableD
param1 <- subset(plot.data, plot.data[, id_cols] %in% groups[1])
param2 <- subset(plot.data, plot.data[, id_cols] %in% groups[2])

title <- TADA_InsertBreaks(
title <- stringr::str_wrap(
paste0(
param1$TADA.CharacteristicName[1],
" and ",
param2$TADA.CharacteristicName[1],
" Over Time"
),
len = 45
width = 45
)

# figure margin
Expand Down Expand Up @@ -1370,13 +1370,13 @@ TADA_GroupedScatterplot <- function(.data, group_col = "MonitoringLocationName",
all_scatterplots <- list()

for (i in 1:length(unique(plot.data$TADA.ComparableDataIdentifier))) {
title <- TADA_InsertBreaks(
title <- stringr::str_wrap(
paste0(
"Scatterplot of ",
TADA_CharStringRemoveNA(unique(plot.data$TADA.ComparableDataIdentifier)[i]),
" Over Time"
),
len = 45
width = 45
)

# figure margin
Expand Down
28 changes: 0 additions & 28 deletions R/Utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -140,34 +140,6 @@ TADA_DecimalPlaces <- function(x) {
}
}

#' Insert Breaks
#'
#' This function inserts a new line into a string when it exceeds a
#' user-specified length. New lines are added to spaces in the string. This is
#' intended to make plot legends more readable and tidy.
#'
#' @param x A vector of strings
#' @param len The maximum character length a string can be before the function
#' searches for the best space to insert a new line.
#'
#' @return The same vector of strings with new lines added where appropriate.
#'
#' @export
TADA_InsertBreaks <- function(x, len = 50) {
if (nchar(x) > len) {
multiples <- floor(nchar(x) / len)
lens <- seq(len, len * multiples, by = len)
spaces <- unlist(gregexpr(" ", x))
if (max(spaces) > len) {
spots <- sapply(lens, function(x) spaces[min(which(spaces > x))])
for (i in 1:length(spots)) {
stringi::stri_sub(x, spots[i] + (i - 1), spots[i]) <- "\n "
}
}
}
return(x)
}

#' Check Type
#'
#' This function checks if the inputs to a function are of the expected type. It
Expand Down
22 changes: 0 additions & 22 deletions man/TADA_InsertBreaks.Rd

This file was deleted.

10 changes: 5 additions & 5 deletions vignettes/GeospatialDataIntegration.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ dependencies for this workflow will be downloaded automatically. We will
also need to install StreamCatTools for some steps later in the
workflow.

```{r devsetup, include = F, eval = T}
remotes::install_github("USEPA/EPATADA",
ref = "geospatial-vignette",
dependencies = TRUE,
force = TRUE)
```{r dev_install, results = 'hide', include = F}
remotes::install_github("USEPA/EPATADA",
ref = "594-tada_insertbreak-bug-report",
dependencies = TRUE
)
library(EPATADA)
```

Expand Down
8 changes: 4 additions & 4 deletions vignettes/TADAAssessmentUnitUseCase.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,9 @@ remotes::install_github("USEPA/EPATADA",

```{r install_TADA_developer, include = FALSE}
remotes::install_github("USEPA/EPATADA",
ref = "prerelease",
ref = "594-tada_insertbreak-bug-report",
dependencies = TRUE
)

library(EPATADA)
```

Expand Down Expand Up @@ -316,8 +315,9 @@ earlydate <- min(Analysis_data$ActivityStartDate)
latedate <- max(Analysis_data$ActivityStartDate)
```

This allows us to easily review how many monitoring locations, organizations,
and results are in the dataframe for the selected time period.
This allows us to easily review how many monitoring locations,
organizations, and results are in the dataframe for the selected time
period.

## Water Chemistry Data Preparation and QC

Expand Down
2 changes: 1 addition & 1 deletion vignettes/TADAModule1.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ remotes::install_github("USEPA/EPATADA",

```{r dev_install, results = 'hide', include = F}
remotes::install_github("USEPA/EPATADA",
ref = "tada_dr_updates_tada_team",
ref = "594-tada_insertbreak-bug-report",
dependencies = TRUE
)
```
Expand Down
2 changes: 1 addition & 1 deletion vignettes/TADAModule1_AdvancedTraining.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ developers/contributors.
```{r install_TADA_dev, eval = F, include = F}
# helps with development (knit and checks), this chunk should not appear on the pkgdown website
remotes::install_github("USEPA/EPATADA",
ref = "prerelease",
ref = "594-tada_insertbreak-bug-report",
dependencies = TRUE
)
```
Expand Down
2 changes: 1 addition & 1 deletion vignettes/TADAModule1_BeginnerTraining.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ remotes::install_github("USEPA/EPATADA",

```{r install_TADA_developer, eval = F, include = F}
remotes::install_github("USEPA/EPATADA",
ref = "prerelease",
ref = "594-tada_insertbreak-bug-report",
dependencies = TRUE
)

Expand Down
7 changes: 7 additions & 0 deletions vignettes/TADAModule2.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ remotes::install_github("USEPA/EPATADA",
)
```

```{r dev_install, results = 'hide', include = F}
remotes::install_github("USEPA/EPATADA",
ref = "594-tada_insertbreak-bug-report",
dependencies = TRUE
)
```

Finally, use the **library()** function to load the TADA R Package into
your R session.

Expand Down
2 changes: 1 addition & 1 deletion vignettes/TADAModule3_PartA.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ update all of them (enter 1 into the console).
```{r install_TADA_dev, include = F}
# helps with development (knit and checks), this chunk should not appear on the pkgdown website
remotes::install_github("USEPA/EPATADA",
ref = "prerelease",
ref = "594-tada_insertbreak-bug-report",
dependencies = TRUE
)
```
Expand Down
17 changes: 16 additions & 1 deletion vignettes/TADAWaterSciConWorkshopDemo.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,20 @@ for TADA package installation instructions.)
We'll also record the start time for our analysis, beginning after
loading packages.

```{r install_TADA, results = 'hide'}
remotes::install_github("USEPA/EPATADA",
ref = "develop",
dependencies = TRUE
)
```

```{r install_TADA_developer, include = FALSE}
remotes::install_github("USEPA/EPATADA",
ref = "594-tada_insertbreak-bug-report",
dependencies = TRUE
)
```

```{r library, results = 'hide'}
# Load required packages
library(EPATADA)
Expand All @@ -76,6 +90,7 @@ library(sf)
library(lubridate)
library(knitr)
library(DT)
library(stringr)


# Record start time
Expand Down Expand Up @@ -508,7 +523,7 @@ twochar_scatter <- TADA_TwoCharacteristicScatterplot(
# remove default plot features that are not applicable for a location comparison
plotly::layout(
yaxis2 = list(overlaying = "y", side = "right", title = "", visible = FALSE),
title = TADA_InsertBreaks("SPECIFIC CONDUCTANCE for the San Juan and Animas Rivers Over Time")
title = stringr::str_wrap("SPECIFIC CONDUCTANCE for the San Juan and Animas Rivers Over Time", width = 50)
)

# modify plot titles to reflect group/location names
Expand Down