Change T and F to TRUE and FALSE

TRUE and FALSE are keywords whereas T and F are just predefined variables that can be reassigned
This commit is contained in:
Joe Cheng
2012-10-31 11:35:41 -07:00
parent fb784ce962
commit 81723d55ac
11 changed files with 55 additions and 55 deletions

View File

@@ -584,10 +584,10 @@ sliderInput <- function(inputId, label, min, max, value, step = NULL,
if (!is.character(labelText))
stop("label not specified")
if (identical(animate, T))
if (identical(animate, TRUE))
animate <- animationOptions()
if (!is.null(animate) && !identical(animate, F)) {
if (!is.null(animate) && !identical(animate, FALSE)) {
if (is.null(animate$playButton))
animate$playButton <- tags$i(class='icon-play')
if (is.null(animate$pauseButton))

View File

@@ -41,7 +41,7 @@ FileUploadOperation <- setRefClass(
filename <- file.path(.dir, as.character(length(.files)))
row <- data.frame(name=file$name, size=file$size, type=file$type,
datapath=filename, stringsAsFactors=F)
datapath=filename, stringsAsFactors=FALSE)
if (length(.files) == 0)
.files <<- row
@@ -74,7 +74,7 @@ FileUploadContext <- setRefClass(
.basedir <<- dir
},
createUploadOperation = function() {
while (T) {
while (TRUE) {
id <- paste(as.raw(runif(12, min=0, max=0xFF)), collapse='')
dir <- file.path(.basedir, id)
if (!dir.create(dir))

14
R/map.R
View File

@@ -20,30 +20,30 @@ Map <- setRefClass(
},
get = function(key) {
if (.self$containsKey(key))
return(base::get(key, pos=.env, inherits=F))
return(base::get(key, pos=.env, inherits=FALSE))
else
return(NULL)
},
set = function(key, value) {
assign(key, value, pos=.env, inherits=F)
assign(key, value, pos=.env, inherits=FALSE)
return(value)
},
remove = function(key) {
if (.self$containsKey(key)) {
result <- .self$get(key)
rm(list = key, pos=.env, inherits=F)
rm(list = key, pos=.env, inherits=FALSE)
return(result)
}
return(NULL)
},
containsKey = function(key) {
exists(key, where=.env, inherits=F)
exists(key, where=.env, inherits=FALSE)
},
keys = function() {
ls(envir=.env, all.names=T)
ls(envir=.env, all.names=TRUE)
},
values = function() {
mget(.self$keys(), envir=.env, inherits=F)
mget(.self$keys(), envir=.env, inherits=FALSE)
},
clear = function() {
.env <<- new.env(parent=emptyenv())
@@ -67,7 +67,7 @@ Map <- setRefClass(
as.list.Map <- function(map) {
sapply(map$keys(),
map$get,
simplify=F)
simplify=FALSE)
}
length.Map <- function(map) {
map$size()

View File

@@ -9,7 +9,7 @@ Context <- setRefClass(
methods = list(
initialize = function() {
id <<- .getReactiveEnvironment()$nextId()
.invalidated <<- F
.invalidated <<- FALSE
.callbacks <<- list()
.hintCallbacks <<- list()
},
@@ -32,7 +32,7 @@ Context <- setRefClass(
invalidated until the next call to \\code{\\link{flushReact}}."
if (.invalidated)
return()
.invalidated <<- T
.invalidated <<- TRUE
.getReactiveEnvironment()$addPendingInvalidate(.self)
NULL
},
@@ -107,10 +107,10 @@ ReactiveEnvironment <- setRefClass(
)
.getReactiveEnvironment <- function() {
if (!exists('.ReactiveEnvironment', envir=.GlobalEnv, inherits=F)) {
if (!exists('.ReactiveEnvironment', envir=.GlobalEnv, inherits=FALSE)) {
assign('.ReactiveEnvironment', ReactiveEnvironment$new(), envir=.GlobalEnv)
}
get('.ReactiveEnvironment', envir=.GlobalEnv, inherits=F)
get('.ReactiveEnvironment', envir=.GlobalEnv, inherits=FALSE)
}
# Causes any pending invalidations to run.

View File

@@ -52,21 +52,21 @@ Values <- setRefClass(
get = function(key) {
ctx <- .getReactiveEnvironment()$currentContext()
dep.key <- paste(key, ':', ctx$id, sep='')
if (!exists(dep.key, where=.dependencies, inherits=F)) {
assign(dep.key, ctx, pos=.dependencies, inherits=F)
if (!exists(dep.key, where=.dependencies, inherits=FALSE)) {
assign(dep.key, ctx, pos=.dependencies, inherits=FALSE)
ctx$onInvalidate(function() {
rm(list=dep.key, pos=.dependencies, inherits=F)
rm(list=dep.key, pos=.dependencies, inherits=FALSE)
})
}
if (!exists(key, where=.values, inherits=F))
if (!exists(key, where=.values, inherits=FALSE))
NULL
else
base::get(key, pos=.values, inherits=F)
base::get(key, pos=.values, inherits=FALSE)
},
set = function(key, value) {
if (exists(key, where=.values, inherits=F)) {
if (identical(base::get(key, pos=.values, inherits=F), value)) {
if (exists(key, where=.values, inherits=FALSE)) {
if (identical(base::get(key, pos=.values, inherits=FALSE), value)) {
return(invisible())
}
}
@@ -75,11 +75,11 @@ Values <- setRefClass(
}
.allDeps$invalidate()
assign(key, value, pos=.values, inherits=F)
assign(key, value, pos=.values, inherits=FALSE)
dep.keys <- objects(
pos=.dependencies,
pattern=paste('^\\Q', key, ':', '\\E', '\\d+$', sep=''),
all.names=T
all.names=TRUE
)
lapply(
mget(dep.keys, envir=.dependencies),
@@ -99,7 +99,7 @@ Values <- setRefClass(
},
names = function() {
.namesDeps$register()
return(ls(.values, all.names=T))
return(ls(.values, all.names=TRUE))
},
toList = function() {
.allDeps$register()
@@ -153,11 +153,11 @@ Observable <- setRefClass(
"or more parameters; only functions without parameters can be ",
"reactive.")
.func <<- func
.initialized <<- F
.initialized <<- FALSE
},
getValue = function() {
if (!.initialized) {
.initialized <<- T
.initialized <<- TRUE
.self$.updateValue()
}
@@ -178,7 +178,7 @@ Observable <- setRefClass(
.dependencies$invalidateHint()
})
ctx$run(function() {
.value <<- try(.func(), silent=F)
.value <<- try(.func(), silent=FALSE)
})
if (!identical(old.value, .value)) {
.dependencies$invalidate()

View File

@@ -47,7 +47,7 @@ ShinyApp <- setRefClass(
obs <- Observer$new(function() {
value <- try(func(), silent=F)
value <- try(func(), silent=FALSE)
.invalidatedOutputErrors$remove(name)
.invalidatedOutputValues$remove(name)
@@ -106,7 +106,7 @@ ShinyApp <- setRefClass(
},
dispatch = function(msg) {
method <- paste('@', msg$method, sep='')
func <- try(do.call(`$`, list(.self, method)), silent=T)
func <- try(do.call(`$`, list(.self, method)), silent=TRUE)
if (inherits(func, 'try-error')) {
.sendErrorResponse(msg, paste('Unknown method', msg$method))
}
@@ -133,9 +133,9 @@ ShinyApp <- setRefClass(
.write(toJSON(list(response=list(tag=requestMsg$tag, error=error))))
},
.write = function(json) {
if (getOption('shiny.trace', F))
if (getOption('shiny.trace', FALSE))
message('SEND ', json)
if (getOption('shiny.transcode.json', T))
if (getOption('shiny.transcode.json', TRUE))
json <- iconv(json, to='UTF-8')
websocket_write(json, .websocket)
},
@@ -185,8 +185,8 @@ resolve <- function(dir, relpath) {
abs.path <- file.path(dir, relpath)
if (!file.exists(abs.path))
return(NULL)
abs.path <- normalizePath(abs.path, winslash='/', mustWork=T)
dir <- normalizePath(dir, winslash='/', mustWork=T)
abs.path <- normalizePath(abs.path, winslash='/', mustWork=TRUE)
dir <- normalizePath(dir, winslash='/', mustWork=TRUE)
if (nchar(abs.path) <= nchar(dir) + 1)
return(NULL)
if (substr(abs.path, 1, nchar(dir)) != dir ||
@@ -266,7 +266,7 @@ dynamicHandler <- function(filePath, dependencyFiles=filePath) {
clearClients()
if (file.exists(filePath)) {
local({
source(filePath, local=T)
source(filePath, local=TRUE)
})
}
metaHandler <<- joinHandlers(.globals$clients)
@@ -358,7 +358,7 @@ registerClient <- function(client) {
#' @export
addResourcePath <- function(prefix, directoryPath) {
prefix <- prefix[1]
if (!grepl('^[a-z][a-z0-9\\-_]*$', prefix, ignore.case=T, perl=T)) {
if (!grepl('^[a-z][a-z0-9\\-_]*$', prefix, ignore.case=TRUE, perl=TRUE)) {
stop("addResourcePath called with invalid prefix; please see documentation")
}
@@ -367,7 +367,7 @@ addResourcePath <- function(prefix, directoryPath) {
"please use a different prefix")
}
directoryPath <- normalizePath(directoryPath, mustWork=T)
directoryPath <- normalizePath(directoryPath, mustWork=TRUE)
existing <- .globals$resources[[prefix]]
@@ -387,7 +387,7 @@ addResourcePath <- function(prefix, directoryPath) {
resourcePathHandler <- function(ws, header) {
path <- header$RESOURCE
match <- regexpr('^/([^/]+)/', path, perl=T)
match <- regexpr('^/([^/]+)/', path, perl=TRUE)
if (match == -1)
return(NULL)
len <- attr(match, 'capture.length')
@@ -448,7 +448,7 @@ decodeMessage <- function(data) {
}
if (readInt(1) != 0x01020202L)
return(fromJSON(rawToChar(data), asText=T, simplify=F))
return(fromJSON(rawToChar(data), asText=TRUE, simplify=FALSE))
i <- 5
parts <- list()
@@ -514,13 +514,13 @@ startApp <- function(port=8101L) {
stop(paste("server.R file was not found in", getwd()))
if (file.exists(globalR))
source(globalR, local=F)
source(globalR, local=FALSE)
shinyServer(NULL)
serverFileTimestamp <- NULL
local({
serverFileTimestamp <<- file.info(serverR)$mtime
source(serverR, local=T)
source(serverR, local=TRUE)
if (is.null(.globals$server))
stop("No server was defined in server.R")
})
@@ -543,7 +543,7 @@ startApp <- function(port=8101L) {
}, ws_env)
set_callback('receive', function(DATA, WS, ...) {
if (getOption('shiny.trace', F)) {
if (getOption('shiny.trace', FALSE)) {
if (as.raw(0) %in% DATA)
message("RECV ", '$$binary data$$')
else
@@ -575,7 +575,7 @@ startApp <- function(port=8101L) {
)
}
else if (is.list(val) && is.null(names(val)))
msg$data[[name]] <- unlist(val, recursive=F)
msg$data[[name]] <- unlist(val, recursive=FALSE)
}
}
@@ -589,7 +589,7 @@ startApp <- function(port=8101L) {
shinyServer(NULL)
local({
serverFileTimestamp <<- mtime
source(serverR, local=T)
source(serverR, local=TRUE)
if (is.null(.globals$server))
stop("No server was defined in server.R")
})
@@ -619,7 +619,7 @@ startApp <- function(port=8101L) {
# NOTE: we de-roxygenized this comment because the function isn't exported
# Run an application that was created by \code{\link{startApp}}. This
# function should normally be called in a \code{while(T)} loop.
# function should normally be called in a \code{while(TRUE)} loop.
#
# @param ws_env The return value from \code{\link{startApp}}.
serviceApp <- function(ws_env) {
@@ -675,7 +675,7 @@ runApp <- function(appDir=getwd(),
}
tryCatch(
while (T) {
while (TRUE) {
serviceApp(ws_env)
},
finally = {

View File

@@ -78,7 +78,7 @@ reactiveTable <- function(func, ...) {
print(xtable(data, ...),
type='html',
html.table.attributes=paste('class="',
htmlEscape(classNames, T),
htmlEscape(classNames, TRUE),
'"',
sep=''))),
collapse="\n"))

View File

@@ -70,7 +70,7 @@ slider <- function(inputId, min, max, value, step = NULL, ...,
}
# Default state is to not have ticks
if (identical(ticks, T)) {
if (identical(ticks, TRUE)) {
# Automatic ticks
tickCount <- (range / step) + 1
if (tickCount <= 26)
@@ -119,10 +119,10 @@ slider <- function(inputId, min, max, value, step = NULL, ...,
'data-smooth'=FALSE)
)
if (identical(animate, T))
if (identical(animate, TRUE))
animate <- animationOptions()
if (!is.null(animate) && !identical(animate, F)) {
if (!is.null(animate) && !identical(animate, FALSE)) {
if (is.null(animate$playButton))
animate$playButton <- 'Play'
if (is.null(animate$pauseButton))

View File

@@ -16,7 +16,7 @@ htmlEscape <- local({
)
.htmlSpecialsPatternAttrib <- paste(names(.htmlSpecialsAttrib), collapse='|')
function(text, attribute=T) {
function(text, attribute=TRUE) {
pattern <- if(attribute)
.htmlSpecialsPatternAttrib
else
@@ -32,7 +32,7 @@ htmlEscape <- local({
.htmlSpecials
for (chr in names(specials)) {
text <- gsub(chr, specials[[chr]], text, fixed=T)
text <- gsub(chr, specials[[chr]], text, fixed=TRUE)
}
return(text)

View File

@@ -51,7 +51,7 @@ TimerCallbacks <- setRefClass(
executeElapsed = function() {
elapsed <- takeElapsed()
if (length(elapsed) == 0)
return(F)
return(FALSE)
for (id in elapsed$id) {
thisFunc <- .funcs$remove(as.character(id))
@@ -59,7 +59,7 @@ TimerCallbacks <- setRefClass(
# TODO: Detect NULL, and...?
thisFunc()
}
return(T)
return(TRUE)
}
)
)

View File

@@ -27,7 +27,7 @@ shinyUI(pageWithSidebar(
# Animation with custom interval (in ms) to control speed, plus looping
sliderInput("animation", "Looping Animation:", 1, 2000, 1, step = 10,
animate=animationOptions(interval=300, loop=T))
animate=animationOptions(interval=300, loop=TRUE))
),
# Show a table summarizing the values entered