From 2c3b5027987486d0040501a3c254e106172eb5dc Mon Sep 17 00:00:00 2001 From: Suraj Yerramilli Date: Fri, 6 Jan 2017 17:26:19 -0600 Subject: S3 method consistency part-2 --- NAMESPACE | 2 +- R/idframe.R | 16 +++++++++------- R/nonparam.R | 5 ++--- man/impulseest.Rd | 2 +- man/impulseplot.Rd | 21 +++++++++++++++++++++ man/plot.idframe.Rd | 4 +++- man/plot.idfrd.Rd | 4 +++- man/plot.impulseest.Rd | 21 --------------------- 8 files changed, 40 insertions(+), 35 deletions(-) create mode 100644 man/impulseplot.Rd delete mode 100644 man/plot.impulseest.Rd diff --git a/NAMESPACE b/NAMESPACE index 0ddac80..4e8b9a5 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -14,7 +14,6 @@ S3method(outputNames,idframe) S3method(plot,estpoly) S3method(plot,idframe) S3method(plot,idfrd) -S3method(plot,impulseest) S3method(predict,estpoly) S3method(print,estpoly) S3method(print,idpoly) @@ -45,6 +44,7 @@ export(idfrd) export(idinput) export(idpoly) export(impulseest) +export(impulseplot) export(inputData) export(inputNames) export(iv) diff --git a/R/idframe.R b/R/idframe.R index c666b55..e619fca 100644 --- a/R/idframe.R +++ b/R/idframe.R @@ -57,6 +57,7 @@ idframe <- function(output,input=NULL,Ts = 1,start=0,end=NULL, #' @param lwd line width, in millimeters(Default=\code{1}) #' @param main the plot title. (Default = \code{NULL}) #' @param size text size (Default = \code{12}) +#' @param \ldots additional arguments #' #' @examples #' data(cstr) @@ -65,7 +66,7 @@ idframe <- function(output,input=NULL,Ts = 1,start=0,end=NULL, #' @import ggplot2 reshape2 #' #' @export -plot.idframe <- function(x,col="steelblue",lwd=1,main=NULL,size=12){ +plot.idframe <- function(x,col="steelblue",lwd=1,main=NULL,size=12,...){ loadNamespace("ggplot2") if(nInputSeries(x)==0){ data <- outputData(x) @@ -82,12 +83,12 @@ plot.idframe <- function(x,col="steelblue",lwd=1,main=NULL,size=12){ } #' @export -summary.idframe <- function(x){ - out_sum <- summary(outputData(x)) - in_sum <- summary(inputData(x)) +summary.idframe <- function(object,...){ + out_sum <- summary(outputData(object)) + in_sum <- summary(inputData(object)) - out <- list(out_sum=out_sum,in_sum=in_sum,Ts=deltat(x), - unit=x$unit,nsample = dim(outputData(x))[1]) + out <- list(out_sum=out_sum,in_sum=in_sum,Ts=deltat(object), + unit=object$unit,nsample = dim(outputData(object))[1]) class(out) <- "summary.idframe" return(out) @@ -190,6 +191,7 @@ idfrd <- function(respData,freq,Ts,spec=NULL,covData=NULL, #' @param col a specification for the line colour (Default : \code{" #' steelblue"}) #' @param lwd the line width, a positive number, defaulting to 1 +#' @param \ldots additional arguments #' #' @seealso \code{\link[ggplot2]{ggplot}} #' @@ -200,7 +202,7 @@ idfrd <- function(respData,freq,Ts,spec=NULL,covData=NULL, #' @import ggplot2 reshape2 signal #' #' @export -plot.idfrd <- function(x,col="steelblue",lwd=1){ +plot.idfrd <- function(x,col="steelblue",lwd=1,...){ loadNamespace("ggplot2") nfreq <- dim(x$freq)[1] mag <- 20*log10(Mod(x$resp)) diff --git a/R/nonparam.R b/R/nonparam.R index 75b26b4..8e8e412 100644 --- a/R/nonparam.R +++ b/R/nonparam.R @@ -27,7 +27,7 @@ #' yk <- filter (uk,c(0.9,-0.4),method="recursive") + rnorm(1000,1) #' data <- idframe(output=data.frame(yk),input=data.frame(uk)) #' fit <- impulseest(data) -#' plot(fit) +#' impulseplot(fit) #' #' @export impulseest <- function(x,M=30,K=NULL,regul=F,lambda=1){ @@ -90,8 +90,7 @@ impulsechannel <- function(y,u,N,M,K=0,regul=F,lambda=1){ #' @import ggplot2 #' #' @export -plot.impulseest <- function(model,sd=2){ - loadNamespace("ggplot2") +impulseplot <- function(model,sd=2){ plotseq <- seq(model$noutputs*model$ninputs) g <- vector("list",model$nin*model$nout) diff --git a/man/impulseest.Rd b/man/impulseest.Rd index 4852d2c..4247a0f 100644 --- a/man/impulseest.Rd +++ b/man/impulseest.Rd @@ -33,7 +33,7 @@ uk <- rnorm(1000,1) yk <- filter (uk,c(0.9,-0.4),method="recursive") + rnorm(1000,1) data <- idframe(output=data.frame(yk),input=data.frame(uk)) fit <- impulseest(data) -plot(fit) +impulseplot(fit) } \references{ diff --git a/man/impulseplot.Rd b/man/impulseplot.Rd new file mode 100644 index 0000000..0e7ced3 --- /dev/null +++ b/man/impulseplot.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/nonparam.R +\name{impulseplot} +\alias{impulseplot} +\title{Impulse Response Plots} +\usage{ +impulseplot(model, sd = 2) +} +\arguments{ +\item{model}{an object of class \code{impulseest}} + +\item{sd}{standard deviation of the confidence region (Default: \code{2})} +} +\description{ +Plots the estimated IR coefficients along with the significance limits +at each lag. +} +\seealso{ +\code{\link{impulseest}},\code{\link{step}} +} + diff --git a/man/plot.idframe.Rd b/man/plot.idframe.Rd index 2a34888..2e7948d 100644 --- a/man/plot.idframe.Rd +++ b/man/plot.idframe.Rd @@ -5,7 +5,7 @@ \title{Plotting idframe objects} \usage{ \method{plot}{idframe}(x, col = "steelblue", lwd = 1, main = NULL, - size = 12) + size = 12, ...) } \arguments{ \item{x}{an \code{idframe} object} @@ -17,6 +17,8 @@ \item{main}{the plot title. (Default = \code{NULL})} \item{size}{text size (Default = \code{12})} + +\item{\ldots}{additional arguments} } \description{ Plotting method for objects inherting from class \code{idframe} diff --git a/man/plot.idfrd.Rd b/man/plot.idfrd.Rd index d8f85af..435f6d7 100644 --- a/man/plot.idfrd.Rd +++ b/man/plot.idfrd.Rd @@ -4,7 +4,7 @@ \alias{plot.idfrd} \title{Plotting idfrd objects} \usage{ -\method{plot}{idfrd}(x, col = "steelblue", lwd = 1) +\method{plot}{idfrd}(x, col = "steelblue", lwd = 1, ...) } \arguments{ \item{x}{An object of class \code{idframe}} @@ -13,6 +13,8 @@ steelblue"})} \item{lwd}{the line width, a positive number, defaulting to 1} + +\item{\ldots}{additional arguments} } \description{ Generates the bode plot of the given frequency response data. It uses the diff --git a/man/plot.impulseest.Rd b/man/plot.impulseest.Rd deleted file mode 100644 index ac32797..0000000 --- a/man/plot.impulseest.Rd +++ /dev/null @@ -1,21 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/nonparam.R -\name{plot.impulseest} -\alias{plot.impulseest} -\title{Impulse Response Plots} -\usage{ -\method{plot}{impulseest}(model, sd = 2) -} -\arguments{ -\item{model}{an object of class \code{impulseest}} - -\item{sd}{standard deviation of the confidence region (Default: \code{2})} -} -\description{ -Plots the estimated IR coefficients along with the significance limits -at each lag. -} -\seealso{ -\code{\link{impulseest}},\code{\link{step}} -} - -- cgit