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 @@
#' @name polyGui
#'
#' @description This function opens an interface to control the
#' polynomial degree in linear regression. It shows the observed values
#' and the corresponding fitted curve superimposed with confidence bands
#' (for the fitted values) and also show the residuals plot. It assumes
#' that \code{gWidgets} and \code{gWidgetstcltk} packages are available.
#' polynomial degree in linear regression. It shows the observed
#' values and the corresponding fitted curve superimposed with
#' confidence bands (for the fitted values) and also show the
#' residuals plot. It assumes 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
#' range by a fraction on both sides and directions. Default is
#' 0.05. See \link[grDevices]{extendrange}.
......@@ -85,13 +84,14 @@ polyGui <- 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)),
gWidgets::svalue(degree) <- min(c(
max(c(1L, gWidgets::svalue(degree)+h$action$val)),
maxd))
m0 <- lm(y~poly(x, degree=svalue(degree)))
switch(svalue(plottype),
m0 <- lm(y~poly(x, degree=gWidgets::svalue(degree)))
switch(gWidgets::svalue(plottype),
"Scatter plot"={
cb <- predict(m0, newdata=newdata, interval="confidence")
cb <- predict(m0, newdata=newdata,
interval="confidence")
plot(y~x, xlim=xr, ylim=yr,
xlab=xlab, ylab=ylab)
matlines(newdata$x, cb, lty=c(1,2,2), col=1)
......@@ -107,30 +107,30 @@ polyGui <- 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)
dlabel <- glabel(text="Polynomial degree:",
w <- gWidgets::gwindow(title="Polynomial regression", visible=FALSE)
g <- gWidgets::ggroup(container=w, horizontal=FALSE)
gg_label <- gWidgets::ggroup(container=g)
dlabel <- gWidgets::glabel(text="Polynomial degree:",
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),
container=gg_label)
gg_buttons <- ggroup(container=g)
gminus <- gbutton(text="-",
gg_buttons <- gWidgets::ggroup(container=g)
gminus <- gWidgets::gbutton(text="-",
handler=draw.poly,
action=list(val=-1L),
container=gg_buttons)
gplus <- gbutton(text="+",
gplus <- gWidgets::gbutton(text="+",
handler=draw.poly,
action=list(val=1L),
container=gg_buttons)
gg_radio <- ggroup(container=g)
plottype <- gradio(items=c("Scatter plot", "Residuals"),
gg_radio <- gWidgets::ggroup(container=g)
plottype <- gWidgets::gradio(items=c("Scatter plot", "Residuals"),
horizontal=TRUE,
handler=draw.poly,
action=list(val=0L),
container=gg_radio)
do.call(what=draw.poly, args=list(h=list(degree=1L)))
visible(w) <- TRUE
gWidgets::visible(w) <- TRUE
invisible()
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment