Commit d29ef3c8 authored by QTC.Yulin's avatar QTC.Yulin
Browse files

<fix> rename param

parent 941249b3
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -9,12 +9,12 @@
#' @param nsm number of points used to perform convolution, should less than \code{nbin}, default 10
#' @param addsm number of additional times of revolution performed, default 1
#' @param qval quantile of each sector, used to determine the edge of the hull, should less than 1, default 0.95
#' @param sizefac expansion size factor, larger value means bigger hull, default 1.5
#' @param sfac expansion size factor, larger value means bigger hull, default 1.5
#'
#' @return a list of coordinates of the hull
#'
#' @export
smoothUnchull <- function(x, y, nbin = 100, nsm = 10, addsm = 1, qval = 0.95, sizefac = 1.5) {
smoothUnchull <- function(x, y, nbin = 100, nsm = 10, addsm = 1, qval = 0.95, sfac = 1.5) {

  # convert to polar
  polarDim <- cart2polar(x, y)
@@ -38,7 +38,7 @@ smoothUnchull <- function(x, y, nbin = 100, nsm = 10, addsm = 1, qval = 0.95, si
  }

  # convert back
  polar2cart(smVal * sizefac, 2 * (1:nbin)/nbin, median(x), median(y))
  polar2cart(smVal * sfac, 2 * (1:nbin)/nbin, median(x), median(y))
}

#' cart2polar
@@ -102,9 +102,9 @@ polar2cart <- function(r, t, xm, ym) {
#' @param nsm number of points used to perform convolution, should less than \code{nbin}, default 10
#' @param addsm number of additional times of revolution performed, default 1
#' @param qval quantile of each sector, used to determine the edge of the hull, should less than 1, default 0.95
#' @param sizefac expansion size factor, larger value means bigger hull, default 1.5
#' @param sfac expansion size factor, larger value means bigger hull, default 1.5
#' @inheritParams ggplot2::layer
#' @inheritParams ggplot2::geom_polygen
#' @inheritParams ggplot2::geom_point
#'
#' @import ggplot2
#'
@@ -112,12 +112,12 @@ polar2cart <- function(r, t, xm, ym) {
stat_unchull <- function(
  mapping = NULL, data = NULL, geom = "polygon",
  position = "identity", na.rm = F, show.legend = NA,
  inherit.aes = T, nbin = 100, nsm = 10, addsm = 1, qval = 0.95, sizefac = 1.5, ...) {
  inherit.aes = T, nbin = 100, nsm = 10, addsm = 1, qval = 0.95, sfac = 1.5, ...) {

  layer(
    stat = StatUnchull, data = data, mapping = mapping, geom = geom,
    position = position, show.legend = show.legend, inherit.aes = inherit.aes,
    params = list(na.rm = na.rm, nbin = nbin, nsm = nsm, addsm = addsm, qval = qval, sizefac = sizefac, ...)
    params = list(na.rm = na.rm, nbin = nbin, nsm = nsm, addsm = addsm, qval = qval, sfac = sfac, ...)
  )
}

@@ -131,10 +131,10 @@ StatUnchull <- ggproto(
  required_aes = c("x", "y"),

  compute_group = function(
    data, scales, params, nbin = 100, nsm = 10, addsm = 1, qval = 0.95, sizefac = 1.5) {
    data, scales, params, nbin = 100, nsm = 10, addsm = 1, qval = 0.95, sfac = 1.5) {

    chullData <- smoothUnchull(
      data$x, data$y, nbin = nbin, nsm = nsm, addsm = addsm, qval = qval, sizefac = sizefac)
      data$x, data$y, nbin = nbin, nsm = nsm, addsm = addsm, qval = qval, sfac = sfac)

    data.frame(x = chullData$x, y = chullData$y)
  }
+2 −2
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
\title{smoothUnchull}
\usage{
smoothUnchull(x, y, nbin = 100, nsm = 10, addsm = 1, qval = 0.95,
  sizefac = 1.5)
  sfac = 1.5)
}
\arguments{
\item{x}{a vector of x coordinates}
@@ -20,7 +20,7 @@ smoothUnchull(x, y, nbin = 100, nsm = 10, addsm = 1, qval = 0.95,

\item{qval}{quantile of each sector, used to determine the edge of the hull, should less than 1, default 0.95}

\item{sizefac}{expansion size factor, larger value means bigger hull, default 1.5}
\item{sfac}{expansion size factor, larger value means bigger hull, default 1.5}
}
\value{
a list of coordinates of the hull
+10 −2
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@
stat_unchull(mapping = NULL, data = NULL, geom = "polygon",
  position = "identity", na.rm = F, show.legend = NA,
  inherit.aes = T, nbin = 100, nsm = 10, addsm = 1, qval = 0.95,
  sizefac = 1.5, ...)
  sfac = 1.5, ...)
}
\arguments{
\item{mapping}{Set of aesthetic mappings created by \code{\link[=aes]{aes()}} or
@@ -35,6 +35,9 @@ from a \code{formula} (e.g. \code{~ head(.x, 10)}).}
\item{position}{Position adjustment, either as a string, or the result of
a call to a position adjustment function.}

\item{na.rm}{If \code{FALSE}, the default, missing values are removed with
a warning. If \code{TRUE}, missing values are silently removed.}

\item{show.legend}{logical. Should this layer be included in the legends?
\code{NA}, the default, includes if any aesthetics are mapped.
\code{FALSE} never includes, and \code{TRUE} always includes.
@@ -54,7 +57,12 @@ the default plot specification, e.g. \code{\link[=borders]{borders()}}.}

\item{qval}{quantile of each sector, used to determine the edge of the hull, should less than 1, default 0.95}

\item{sizefac}{expansion size factor, larger value means bigger hull, default 1.5}
\item{sfac}{expansion size factor, larger value means bigger hull, default 1.5}

\item{...}{Other arguments passed on to \code{\link[=layer]{layer()}}. These are
often aesthetics, used to set an aesthetic to a fixed value, like
\code{colour = "red"} or \code{size = 3}. They may also be parameters
to the paired geom/stat.}
}
\description{
A ggplot function used to get a hull of input set of points. The hull can be non-convex.