Skip to content

Commit

Permalink
RC
Browse files Browse the repository at this point in the history
  • Loading branch information
edwbaker committed Dec 19, 2019
1 parent 5eeeb7a commit 22dafe7
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 33 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
@@ -1,11 +1,11 @@
Package: tdsc
Title: Time Domain Signal Coding
Version: 1.0.2
Version: 1.0.3
Authors@R: person("Ed", "Baker", email = "ed@ebaker.me.uk", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-5887-9543"))
Description: Functions for performing time domain signal coding as used in Chesmore (2001) <doi:10.1016/S0003-682X(01)00009-3>, and related tasks. This package creates the standard S-matrix and A-matrix (with variable lag), has tools to convert coding matrices into distributed matrices, provides published codebooks and allows for extraction of code sequences.
Depends: R (>= 3.5.0)
License: GPL-3
Language: en-UK
Language: en-GB
Encoding: UTF-8
LazyData: true
RoxygenNote: 6.1.1
Expand Down
5 changes: 4 additions & 1 deletion NEWS.md
@@ -1,4 +1,7 @@
# tdsc 1.0.3
* Allow passing of arguments to plotting functions via tdsc.plot

# tdsc 1.0.2
* New wrapper functions compatible with sonicscrewdriver windowing
* Helper functionality for plotting A matrices
* Added a `NEWS.md` file to track changes to the package.
* Added a `NEWS.md` file to track changes to the package.
23 changes: 13 additions & 10 deletions R/followingCodes.R
@@ -1,13 +1,14 @@
#' Following Codes
#'
#'
#' Identifies sequences of codes that follow each other from time domain signal analysis, and optionally plots them as a Sankey diagram.
#'
#'
#' @param tdsc A TDSC object
#' @param depth The length of the sequence of codes to search for
#' @param min_code The minimum value of code to include in sequence
#' @param max_code The maximum value of code to include in sequence
#' @param colourCode If plot is alluvial, colour all codes following this code
#' @param plot If "alluvial" plots the found sequences in a river plot
#' @param ... Arguments to pass to the plotting function
#' @keywords TDSC
#' @export
#' @examples
Expand All @@ -18,12 +19,13 @@
#' followingCodes(t)
#' followingCodes(t, colourCode=2,plot="alluvial")
#' }
followingCodes <- function (tdsc,
depth=2,
min_code=0,
followingCodes <- function (tdsc,
depth=2,
min_code=0,
max_code=10,
colourCode=1,
plot=F) {
plot=F,
...) {
codelist <- tdsc@codelist
fs <- c()
p <- cbind(min_code:max_code)
Expand All @@ -46,10 +48,10 @@ followingCodes <- function (tdsc,
}
}
p <- p_found

}
colnames(fs) <- c(paste0(rep("Code", depth+1), 1:(depth+1)), "Freq")

if (plot=="alluvial") {
if (!requireNamespace("alluvial", quietly=TRUE)) {
stop()
Expand All @@ -58,8 +60,9 @@ followingCodes <- function (tdsc,
alluvial::alluvial( f[,1:(depth+1)], freq=f$Freq, border=NA,
hide = f$Freq < stats::quantile(f$Freq, .50),
col=ifelse( f$Code1 == colourCode,
"red", "grey")
"red", "grey"),
...
)
}
return(fs)
}
}
25 changes: 15 additions & 10 deletions R/plot.R
Expand Up @@ -4,6 +4,7 @@
#'
#' @param td A TDSC object
#' @param plotter Function used to plot the A matrix (persp or perp3D) or S matrix (hist)
#' @param ... Parameters to pass to plotting function
#' @export
#' @examples
#' \dontrun{
Expand All @@ -14,36 +15,40 @@
#'
tdsc.plot <- function(
td,
plotter="persp"
plotter="persp",
...
){
if (plotter=="persp") {
plot.a.persp(td)
plot.a.persp(td, ...)
}
if (plotter=="persp3D") {
plot.a.persp3D(td)
plot.a.persp3D(td, ...)
}
if (plotter=="hist") {
plot.s.hist(td)
plot.s.hist(td, ...)
}
}

plot.a.persp <- function(td) {
plot.a.persp <- function(td, ...) {
graphics::persp(td@a_matrix,
theta = 30, phi = 20,
xlab="Code", ylab="Lagged Code", zlab=""
xlab="Code", ylab="Lagged Code", zlab="",
...
)
}

plot.a.persp3D <- function(td) {
plot.a.persp3D <- function(td, ...) {
package.installed("GA")
GA::persp3D(x=1:nrow(td@a_matrix),y=1:ncol(td@a_matrix),z=td@a_matrix,
xlab="Code", ylab="Lagged Code", zlab=""
xlab="Code", ylab="Lagged Code", zlab="",
...
)
}

plot.s.hist <- function(td) {
plot.s.hist <- function(td, ...) {
graphics::hist(td@codelist,
xlab="Code",
main=""
main="",
...
)
}
6 changes: 3 additions & 3 deletions R/tdsc.w.R
@@ -1,8 +1,8 @@
#' TDSC analysis comaptible with windowing
#' TDSC analysis compatible with windowing
#'
#' Wrapper function for TDSC analysis that is compatable with the windowing function
#' Wrapper function for TDSC analysis that is compatible with the windowing function
#' of the package sonicscrewdriver.
#'
#'
#' @rdname tdsc.w
#' @param start Start position in samples
#' @param wave Wave object to analyse
Expand Down
4 changes: 1 addition & 3 deletions cran-comments.md
Expand Up @@ -5,6 +5,4 @@

## R CMD check results

0 errors | 0 warnings | 1 note

* This is a new release.
0 errors | 0 warnings | 0 notes
8 changes: 8 additions & 0 deletions inst/WORDLIST
@@ -0,0 +1,8 @@
Bioacoustic
Chesmore
Codacy
doi
Orthoptera
perp
persp
sonicscrewdriver
4 changes: 3 additions & 1 deletion man/followingCodes.Rd

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

4 changes: 3 additions & 1 deletion man/tdsc.plot.Rd

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

4 changes: 2 additions & 2 deletions man/tdsc.w.Rd

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

0 comments on commit 22dafe7

Please sign in to comment.