From 7cf5cbe983787aade901af6f0f65545834423352 Mon Sep 17 00:00:00 2001
From: Walmes Zeviani <walmeszeviani@gmail.com>
Date: Mon, 24 Aug 2015 16:38:01 -0300
Subject: [PATCH] Add polyGui function.

---
 R/{poly.gui.R => polyGui.R}     | 26 ++++++++++++++------------
 man/{poly.gui.Rd => polyGui.Rd} |  5 +++--
 2 files changed, 17 insertions(+), 14 deletions(-)
 rename R/{poly.gui.R => polyGui.R} (95%)
 rename man/{poly.gui.Rd => polyGui.Rd} (93%)

diff --git a/R/poly.gui.R b/R/polyGui.R
similarity index 95%
rename from R/poly.gui.R
rename to R/polyGui.R
index 91188f3..05894c8 100644
--- a/R/poly.gui.R
+++ b/R/polyGui.R
@@ -1,6 +1,6 @@
 #' @title Polynomial regression GUI
-#' 
-#' @name poly.gui
+#'
+#' @name polyGui
 #'
 #' @description This function opens a interface to control the
 #' polynomial degree in linear regression. It shows the observed values
@@ -9,7 +9,7 @@
 #' that \code{gWidgets} and \code{gWidgetstcltk} packages are available.
 #'
 #' @param x,y independent and dependent (numeric) regression variables.
-#' 
+#'
 #' @param data an optional \code{data.frame}.
 #'
 #' @param er stands for extend range. It is used to extend the plotting
@@ -18,20 +18,22 @@
 #'
 #' @return None is returned by the function.
 #'
+#' @import gWidgets gWidgetstcltk
+#'
 #' @export
 #' @examples
 #' \donttest{
-#' 
+#'
 #' poly.gui(x=area, y=peri, data=rock, er=0.3)
 #' poly.gui(x=speed, y=dist, data=cars, er=0.3)
 #' poly.gui(x=eruptions, y=waiting, data=faithful, er=0.3)
-#' 
+#'
 #' }
 poly.gui <- function(x, y, data, er=0.05){
     ##
     ##-------------------------------------------
     ## Loading the required packages.
-    ## 
+    ##
     if (!requireNamespace("gWidgets", quietly=TRUE)){
         stop("`gWidgets` needed for this function to work. Please install it.",
              call.=FALSE)
@@ -40,13 +42,13 @@ poly.gui <- function(x, y, data, er=0.05){
         stop("`gWidgetstcltk` needed for this function to work. Please install it.",
              call.=FALSE)
     }
-    stopifnot(require(gWidgets))
-    stopifnot(require(gWidgetstcltk))
+    ## stopifnot(require(gWidgets))
+    ## stopifnot(require(gWidgetstcltk))
     options(guiToolkit="tcltk")
     ##
     ##-------------------------------------------
     ## Functions to annotate in the plot upper margin.
-    ## 
+    ##
     annotations <- function(lm.obj){
         mtext(side=3, adj=0, line=1.5,
               text=sprintf("X rank: %i", lm.obj$rank))
@@ -60,7 +62,7 @@ poly.gui <- function(x, y, data, er=0.05){
                             sm$coeff[length(coef(lm.obj)), 4])
         mtext(side=3, adj=1, line=2.5, text=lastcoef)
         mtext(side=3, adj=1, line=1.5,
-              text=sprintf("R² (adj. R²): %0.2f (%0.2f)",
+              text=sprintf("R^2 (adj. R^2): %0.2f (%0.2f)",
                   100*sm$r.squared, 100*sm$adj.r.squared))
     }
     ##
@@ -81,7 +83,7 @@ poly.gui <- function(x, y, data, er=0.05){
     ##
     ##-------------------------------------------
     ## Function controled by the GUI.
-    ## 
+    ##
     draw.poly <- function(h, ...){
         svalue(degree) <- min(c(
             max(c(1L, svalue(degree)+h$action$val)),
@@ -104,7 +106,7 @@ poly.gui <- function(x, y, data, er=0.05){
     ##
     ##-------------------------------------------
     ## Building the GUI.
-    ## 
+    ##
     w <- gwindow(title="Polynomial regression", visible=FALSE)
     g <- ggroup(container=w, horizontal=FALSE)
     gg_label <- ggroup(container=g)
diff --git a/man/poly.gui.Rd b/man/polyGui.Rd
similarity index 93%
rename from man/poly.gui.Rd
rename to man/polyGui.Rd
index 479226b..004febd 100644
--- a/man/poly.gui.Rd
+++ b/man/polyGui.Rd
@@ -1,7 +1,8 @@
 % Generated by roxygen2 (4.1.1): do not edit by hand
-% Please edit documentation in R/poly.gui.R
-\name{poly.gui}
+% Please edit documentation in R/polyGui.R
+\name{polyGui}
 \alias{poly.gui}
+\alias{polyGui}
 \title{Polynomial regression GUI}
 \usage{
 poly.gui(x, y, data, er = 0.05)
-- 
GitLab