Skip to content
Snippets Groups Projects
Commit c315d193 authored by Walmes Marques Zeviani's avatar Walmes Marques Zeviani
Browse files

Adds 'gWidgets::' prefix to all its functions.

parent 49ee4a6e
No related branches found
No related tags found
No related merge requests found
...@@ -3,15 +3,14 @@ ...@@ -3,15 +3,14 @@
#' @name polyGui #' @name polyGui
#' #'
#' @description This function opens an interface to control the #' @description This function opens an interface to control the
#' polynomial degree in linear regression. It shows the observed values #' polynomial degree in linear regression. It shows the observed
#' and the corresponding fitted curve superimposed with confidence bands #' values and the corresponding fitted curve superimposed with
#' (for the fitted values) and also show the residuals plot. It assumes #' confidence bands (for the fitted values) and also show the
#' that \code{gWidgets} and \code{gWidgetstcltk} packages are available. #' residuals plot. It assumes that \code{gWidgets} and
#' \code{gWidgetstcltk} packages are available.
#' #'
#' @param x,y independent and dependent (numeric) regression variables. #' @param x,y independent and dependent (numeric) regression variables.
#'
#' @param data an optional \code{data.frame}. #' @param data an optional \code{data.frame}.
#'
#' @param er stands for extend range. It is used to extend the plotting #' @param er stands for extend range. It is used to extend the plotting
#' range by a fraction on both sides and directions. Default is #' range by a fraction on both sides and directions. Default is
#' 0.05. See \link[grDevices]{extendrange}. #' 0.05. See \link[grDevices]{extendrange}.
...@@ -85,13 +84,14 @@ polyGui <- function(x, y, data, er=0.05){ ...@@ -85,13 +84,14 @@ polyGui <- function(x, y, data, er=0.05){
## Function controled by the GUI. ## Function controled by the GUI.
## ##
draw.poly <- function(h, ...){ draw.poly <- function(h, ...){
svalue(degree) <- min(c( gWidgets::svalue(degree) <- min(c(
max(c(1L, svalue(degree)+h$action$val)), max(c(1L, gWidgets::svalue(degree)+h$action$val)),
maxd)) maxd))
m0 <- lm(y~poly(x, degree=svalue(degree))) m0 <- lm(y~poly(x, degree=gWidgets::svalue(degree)))
switch(svalue(plottype), switch(gWidgets::svalue(plottype),
"Scatter plot"={ "Scatter plot"={
cb <- predict(m0, newdata=newdata, interval="confidence") cb <- predict(m0, newdata=newdata,
interval="confidence")
plot(y~x, xlim=xr, ylim=yr, plot(y~x, xlim=xr, ylim=yr,
xlab=xlab, ylab=ylab) xlab=xlab, ylab=ylab)
matlines(newdata$x, cb, lty=c(1,2,2), col=1) matlines(newdata$x, cb, lty=c(1,2,2), col=1)
...@@ -107,30 +107,30 @@ polyGui <- function(x, y, data, er=0.05){ ...@@ -107,30 +107,30 @@ polyGui <- function(x, y, data, er=0.05){
##------------------------------------------- ##-------------------------------------------
## Building the GUI. ## Building the GUI.
## ##
w <- gwindow(title="Polynomial regression", visible=FALSE) w <- gWidgets::gwindow(title="Polynomial regression", visible=FALSE)
g <- ggroup(container=w, horizontal=FALSE) g <- gWidgets::ggroup(container=w, horizontal=FALSE)
gg_label <- ggroup(container=g) gg_label <- gWidgets::ggroup(container=g)
dlabel <- glabel(text="Polynomial degree:", dlabel <- gWidgets::glabel(text="Polynomial degree:",
container=gg_label) container=gg_label)
degree <- gedit(text=1, width=2, coerce.with=as.integer, degree <- gWidgets::gedit(text=1, width=2, coerce.with=as.integer,
handler=draw.poly, action=list(val=0L), handler=draw.poly, action=list(val=0L),
container=gg_label) container=gg_label)
gg_buttons <- ggroup(container=g) gg_buttons <- gWidgets::ggroup(container=g)
gminus <- gbutton(text="-", gminus <- gWidgets::gbutton(text="-",
handler=draw.poly, handler=draw.poly,
action=list(val=-1L), action=list(val=-1L),
container=gg_buttons) container=gg_buttons)
gplus <- gbutton(text="+", gplus <- gWidgets::gbutton(text="+",
handler=draw.poly, handler=draw.poly,
action=list(val=1L), action=list(val=1L),
container=gg_buttons) container=gg_buttons)
gg_radio <- ggroup(container=g) gg_radio <- gWidgets::ggroup(container=g)
plottype <- gradio(items=c("Scatter plot", "Residuals"), plottype <- gWidgets::gradio(items=c("Scatter plot", "Residuals"),
horizontal=TRUE, horizontal=TRUE,
handler=draw.poly, handler=draw.poly,
action=list(val=0L), action=list(val=0L),
container=gg_radio) container=gg_radio)
do.call(what=draw.poly, args=list(h=list(degree=1L))) do.call(what=draw.poly, args=list(h=list(degree=1L)))
visible(w) <- TRUE gWidgets::visible(w) <- TRUE
invisible() invisible()
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment