Skip to content

Commit

Permalink
version 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jjallaire authored and gaborcsardi committed Dec 23, 2014
0 parents commit 895c846
Show file tree
Hide file tree
Showing 14 changed files with 928 additions and 0 deletions.
27 changes: 27 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Package: manipulate
Type: Package
Title: Interactive Plots for RStudio
Version: 1.0.1
Date: 2014-12-23
Authors@R: c(
person("JJ", "Allaire", role = c("aut", "cre"),
comment = "R interface", email = "jj@rstudio.com"),
person(family = "RStudio", role = "cph")
)
Maintainer: JJ Allaire <jj@rstudio.com>
Description: Interactive plotting functions for use within RStudio.
The manipulate function accepts a plotting expression and a set of
controls (e.g. slider, picker, checkbox, or button) which are used
to dynamically change values within the expression. When a value is
changed using its corresponding control the expression is
automatically re-executed and the plot is redrawn.
Depends: R (>= 2.11.1)
SystemRequirements: RStudio - http://www.rstudio.com/products/rstudio/
License: GPL-2
LazyLoad: yes
Packaged: 2014-12-23 18:00:41 UTC; jjallaire
Author: JJ Allaire [aut, cre] (R interface),
RStudio [cph]
NeedsCompilation: no
Repository: CRAN
Date/Publication: 2014-12-24 01:18:44
13 changes: 13 additions & 0 deletions MD5
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
3a15e11fd95821d1ac6e94da03c4bdbe *DESCRIPTION
bed5c561bc810cafdf74ff63f8ad0ff2 *NAMESPACE
d24983e54344a4ef15e3e73dc2df5e4f *R/manipulate-internal.R
3609950f975ff744c303d92c67a3377d *R/manipulate.R
a1e6ed2407ae6a306adfd244456a7fda *man/button.Rd
632a592fcf7d570290c1607703b938d7 *man/checkbox.Rd
742bc15773c05ef01923f2a147be9fd8 *man/isAvailable.Rd
7ef3709a55bb14f2c19f2dc2d30f0d33 *man/manipulate-package.Rd
d39ad73738c42deaba6c8623c758666b *man/manipulate.Rd
bb3b91ee423f0b48649616397d85b4ad *man/mouseclick.Rd
e4b73e5d6f609aa2488637f2553c6b45 *man/picker.Rd
4037c019ba0922690787509808427880 *man/slider.Rd
709d3b5ffa2dd26b44ba3472da441470 *man/state.Rd
11 changes: 11 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

export(slider,
picker,
checkbox,
button,
manipulatorSetState,
manipulatorGetState,
manipulatorMouseClick,
manipulate,
isAvailable)

152 changes: 152 additions & 0 deletions R/manipulate-internal.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
#
# manipulate-internal.R
#
# Copyright (C) 2009-11 by RStudio, Inc.
#
# Unless you have received this program directly from RStudio pursuant
# to the terms of a commercial license agreement with RStudio, then
# this program is licensed to you under the terms of version 3 of the
# GNU Affero General Public License. This program is distributed WITHOUT
# ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
# AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
#
#

manipulatorExecute <- function(manipulator)
{
# evaulate the expression
result <- withVisible(eval(manipulator$.code, envir = manipulator))

# emulate the behavior of the console by printing the result if it
# is visible. this will allow objects returned from e.g. lattice or
# ggplot plots to be displayed without requiring an explicit print
# statement, whereas plotting functions like plot (or custom user
# functions will not print anything assuming they return invisibly.
if (result$visible)
{
# evaluate print in the context of the manipulator's parent
# environment (typically the global environment if manipulate was
# entered directly at the consle). this allows the dispatch of the
# print generic method to find the appropriate class method
eval(print(result$value), enclos=parent.env(manipulator))
}
}

manipulatorSave <- function(manipulator, filename)
{
suppressWarnings(save(manipulator, file=filename))
}

manipulatorLoad <- function(filename)
{
load(filename)
get("manipulator")
}

hasActiveManipulator <- function()
{
.Call(getNativeSymbolInfo("rs_hasActiveManipulator", PACKAGE=""))
}

activeManipulator <- function()
{
.Call(getNativeSymbolInfo("rs_activeManipulator", PACKAGE=""))
}

ensureManipulatorSaved <- function()
{
.Call(getNativeSymbolInfo("rs_ensureManipulatorSaved", PACKAGE=""))
}

createUUID <- function()
{
.Call(getNativeSymbolInfo("rs_createUUID", PACKAGE=""))
}

executeAndAttachManipulator <- function(manipulator)
{
.Call(getNativeSymbolInfo("rs_executeAndAttachManipulator", PACKAGE=""),
manipulator)
}

setManipulatorValue <- function(manipulator, name, value)
{
# assign the user visible value
assign(name, value, envir = get(".userVisibleValues", envir = manipulator))

# calculate the underlying value. if this was a picker then lookup the
# underlying value otherwise use the value passed as-is
underlyingValue <- value
controls <- get(".controls", envir = manipulator)
control <- controls[[name]]
if (inherits(control, "manipulator.picker"))
underlyingValue <- (control$values[[value]])

# assign the value
assign(name, underlyingValue, envir = manipulator)
}

userVisibleValues <- function(manipulator, variables)
{
mget(variables, envir = get(".userVisibleValues", envir = manipulator))
}

buttonNames <- function(manipulator)
{
if (exists(".buttonNames", envir = manipulator))
get(".buttonNames", envir = manipulator)
else
character()
}

trackingMouseClicks <- function(manipulator)
{
exists(".mouseClick", envir = manipulator)
}

setMouseClick <- function(manipulator,
deviceX,
deviceY,
userX,
userY,
ndcX,
ndcY)
{
mouseClick <- list(deviceX = deviceX,
deviceY = deviceY,
userX = userX,
userY = userY,
ndcX = ndcX,
ndcY = ndcY)
assign(".mouseClick", mouseClick, envir = manipulator)
}

clearMouseClick <- function(manipulator)
{
assign(".mouseClick", NULL, envir = manipulator)
}

resolveVariableArguments <- function(args)
{
# if the first argument is an unnamed list then just use this list
if ( (length(args) == 1L) &&
is.list(args[[1L]]) &&
(is.null(names(args)) || (names(args)[[1L]] == "")) )
{
return (args[[1L]])
}
else
{
return (args)
}
}









Loading

0 comments on commit 895c846

Please sign in to comment.