From 265db56acb4ccfc91fddb869d77f81855ffef90d Mon Sep 17 00:00:00 2001 From: benholmgren <44175897+benholmgren@users.noreply.github.com> Date: Wed, 30 Jan 2019 14:16:20 -0700 Subject: [PATCH 1/3] Documentation Additions to kde Specified parameters with roxygen style comments, code functionality also outlined --- R/kde.R | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/R/kde.R b/R/kde.R index 935c952..7a877a7 100644 --- a/R/kde.R +++ b/R/kde.R @@ -1,6 +1,14 @@ kde <- + #'@param X an n by d matrix of coordinates used in kernel density estimation + #'where n is the number of points and d is the dimension + #'@param Grid an m by d matrix of coordinates where m is the number of points and d + #'is the dimension of the base grid referred to in the estimation + #'@param h a desired number to be used as the smoothing parameter of the Gaussian Kernel + #'@param kertype set by default to to use Gaussian kernel + #'@param weight set by default to 1, making all points in X weighted the same unless + #'otherwise specified function(X, Grid, h, kertype = "Gaussian", weight = 1, printProgress = FALSE) { - + # exception handling of inputs to ensure functionality if (!is.numeric(X) && !is.data.frame(X)) { stop("X should be a matrix of coordinates") } @@ -26,7 +34,7 @@ function(X, Grid, h, kertype = "Gaussian", weight = 1, printProgress = FALSE) { if (!is.logical(printProgress)) { stop("printProgress should be a logical variable") } - + # utilize Kde function with inputs return (Kde(X = as.matrix(X), Grid = as.matrix(Grid), h = h, kertype = kertype, weight = weight, printProgress = printProgress)) } From 8384c7cbed61cf61311255802d3c00ef5e261f58 Mon Sep 17 00:00:00 2001 From: benholmgren <44175897+benholmgren@users.noreply.github.com> Date: Mon, 25 Feb 2019 10:16:49 -0700 Subject: [PATCH 2/3] Revised kde comments Removed unnecessary comments for kde function as requested --- R/kde.R | 2 -- 1 file changed, 2 deletions(-) diff --git a/R/kde.R b/R/kde.R index 7a877a7..5d2081e 100644 --- a/R/kde.R +++ b/R/kde.R @@ -8,7 +8,6 @@ kde <- #'@param weight set by default to 1, making all points in X weighted the same unless #'otherwise specified function(X, Grid, h, kertype = "Gaussian", weight = 1, printProgress = FALSE) { - # exception handling of inputs to ensure functionality if (!is.numeric(X) && !is.data.frame(X)) { stop("X should be a matrix of coordinates") } @@ -34,7 +33,6 @@ function(X, Grid, h, kertype = "Gaussian", weight = 1, printProgress = FALSE) { if (!is.logical(printProgress)) { stop("printProgress should be a logical variable") } - # utilize Kde function with inputs return (Kde(X = as.matrix(X), Grid = as.matrix(Grid), h = h, kertype = kertype, weight = weight, printProgress = printProgress)) } From c2a8c7a6452dcf3b2144696b2cc2d9e5639971b9 Mon Sep 17 00:00:00 2001 From: benholmgren <44175897+benholmgren@users.noreply.github.com> Date: Tue, 26 Feb 2019 12:42:40 -0700 Subject: [PATCH 3/3] Now functional roxygen comments Roxygen comments have to be outside function, and needed a title to render properly. Added return value as well. --- R/kde.R | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/R/kde.R b/R/kde.R index 5d2081e..b197304 100644 --- a/R/kde.R +++ b/R/kde.R @@ -1,12 +1,22 @@ +#'@title kde +#' +#'@param X an n by d matrix of coordinates used in kernel density estimation +#'where n is the number of points and d is the dimension +#' +#'@param Grid an m by d matrix of coordinates where m is the number of points and d +#'is the dimension of the base grid referred to in the estimation +#' +#'@param h a desired number to be used as the smoothing parameter of the Gaussian Kernel +#' +#'@param kertype set by default to to use Gaussian kernel +#' +#'@param weight set by default to 1, making all points in X weighted the same unless +#'otherwise specified +#' +#'@return vector of length m (the number of points in the grid) containing the value of +#'the kernel density estimator for each point in the grid + kde <- - #'@param X an n by d matrix of coordinates used in kernel density estimation - #'where n is the number of points and d is the dimension - #'@param Grid an m by d matrix of coordinates where m is the number of points and d - #'is the dimension of the base grid referred to in the estimation - #'@param h a desired number to be used as the smoothing parameter of the Gaussian Kernel - #'@param kertype set by default to to use Gaussian kernel - #'@param weight set by default to 1, making all points in X weighted the same unless - #'otherwise specified function(X, Grid, h, kertype = "Gaussian", weight = 1, printProgress = FALSE) { if (!is.numeric(X) && !is.data.frame(X)) { stop("X should be a matrix of coordinates")