Permalink
Browse files

replace T by TRUE etc to pass checking

  • Loading branch information...
yindeng committed Dec 31, 2014
1 parent 2abb3d8 commit 2557fb78a297588d142df2ff1ff4ed3c9501d3d5
Showing with 185 additions and 186 deletions.
  1. +2 −0 .gitignore
  2. +1 −1 DESCRIPTION
  3. +2 −2 R/main.r
  4. +17 −17 inst/shinyDataApp/data.r
  5. +3 −3 inst/shinyDataApp/global.r
  6. +11 −11 inst/shinyDataApp/helpers.r
  7. +19 −19 inst/shinyDataApp/server.r
  8. +123 −123 inst/shinyDataApp/sheets.r
  9. +6 −6 inst/shinyDataApp/ui.r
  10. +1 −4 man/shinyData.Rd
View
@@ -1,3 +1,5 @@
.Rproj.user
.Rhistory
.RData
*~
View
@@ -10,7 +10,7 @@ Description:
Minimal knowledge of R programming is required to use shinyData.
Suggests:
shiny, reshape, ggplot2, Hmisc, uuid, plotly, tables, tools, png, plyr, shinysky, Cairo
License: MIT
License: MIT + file LICENSE
LazyData: true
URL: http://github.com/yindeng/shinyData
BugReports: http://github.com/yindeng/shinyData/issues
View
@@ -1,8 +1,8 @@
#' Run shinyData
#'
#' This will open your default browser and run shinyData locally on your computer.
#'
#' @export
#' @examples
#' shinyData()
shinyData <- function() {
shiny::runApp(file.path(system.file("shinyDataApp", package = "shinyData")))
}
View
@@ -3,7 +3,7 @@
observe({
v <- input$datList
isolate({
if(!is.empty(input$datList)) projProperties[['activeDat']] <<- v
if(!isEmpty(input$datList)) projProperties[['activeDat']] <<- v
})
})
observe({
@@ -18,8 +18,8 @@ observe({
v <- input$datName
isolate({
currentDat <- (projProperties[['activeDat']])
if(!is.empty(currentDat)){
if(!is.empty(v) && is.empty(datListNames()[v])){
if(!isEmpty(currentDat)){
if(!isEmpty(v) && isEmpty(datListNames()[v])){
datList[[currentDat]][['dynamicProperties']][['name']] <<- v
}
}
@@ -29,7 +29,7 @@ observe({
observe({
updateInput[['datName']]
currentDat <- projProperties[['activeDat']]
s <- if(!is.empty(currentDat)){
s <- if(!isEmpty(currentDat)){
isolate(datList[[currentDat]][['dynamicProperties']][['name']])
} else ''
updateTextInput(session, 'datName', value=null2String(s))
@@ -40,7 +40,7 @@ observe({
activeField <- input$fieldsList
isolate({
currentDat <- (projProperties[['activeDat']])
if(!is.empty(currentDat)){
if(!isEmpty(currentDat)){
datList[[currentDat]][['dynamicProperties']][['activeField']] <<- activeField
}
})
@@ -49,10 +49,10 @@ observe({
observe({
updateInput[['activeField']]
currentDat <- projProperties[['activeDat']]
s <- if(!is.empty(currentDat)){
s <- if(!isEmpty(currentDat)){
isolate(datList[[currentDat]][['dynamicProperties']][['activeField']])
} else ''
choices <- if(!is.empty(currentDat)) datList[[currentDat]][['fieldNames']]()
choices <- if(!isEmpty(currentDat)) datList[[currentDat]][['fieldNames']]()
updateSelectizeInput(session, "fieldsList", choices=null2String(choices),
selected=null2String(s))
})
@@ -62,10 +62,10 @@ observe({
v <- (input$fieldName) #make.names
isolate({
currentDat <- (projProperties[['activeDat']])
if(!is.empty(currentDat)){
if(!isEmpty(currentDat)){
currentField <- (datList[[currentDat]][['dynamicProperties']][['activeField']])
if(!is.empty(currentField)){
if(!is.empty(v) && is.empty((datList[[currentDat]][['fieldNames']]())[v])){
if(!isEmpty(currentField)){
if(!isEmpty(v) && isEmpty((datList[[currentDat]][['fieldNames']]())[v])){
datList[[currentDat]][['dynamicProperties']][['fieldsList']][[currentField]][['name']] <<- v
if(v!=input$fieldName) triggerUpdateInput('fieldName')
}
@@ -78,9 +78,9 @@ observe({
updateInput[['fieldName']]
currentDat <- projProperties[['activeDat']]
s <- ''
if(!is.empty(currentDat)){
if(!isEmpty(currentDat)){
currentField <- datList[[currentDat]][['dynamicProperties']][['activeField']]
if(!is.empty(currentField)){
if(!isEmpty(currentField)){
s <- isolate(datList[[currentDat]][['dynamicProperties']][['fieldsList']][[currentField]][['name']])
}
}
@@ -92,18 +92,18 @@ observe({
newMeasures <- input$measures
isolate({
currentDat <- (projProperties[['activeDat']])
if(!is.empty(currentDat)){
if(!isEmpty(currentDat)){
datList[[currentDat]][['dynamicProperties']][['measures']] <<- newMeasures
}
})
})
observe({
updateInput[['measures']]
currentDat <- projProperties[['activeDat']]
s <- if(!is.empty(currentDat)){
s <- if(!isEmpty(currentDat)){
isolate(datList[[currentDat]][['dynamicProperties']][['measures']])
} else ''
choices <- if(!is.empty(currentDat)) datList[[currentDat]][['fieldNames']]()
choices <- if(!isEmpty(currentDat)) datList[[currentDat]][['fieldNames']]()
updateSelectizeInput(session, "measures", choices=null2String(choices),
selected=null2String(s))
})
@@ -133,13 +133,13 @@ observe({
})
output$uploadingTextFile <- reactive({
T
TRUE
})
outputOptions(output, "uploadingTextFile", suspendWhenHidden=FALSE)
output$datPreview <- renderDataTable({
currentDat <- projProperties[['activeDat']]
if(!is.empty(currentDat)){
if(!isEmpty(currentDat)){
datPrev <- datList[[currentDat]][['datR']]()
names(datPrev) <- names(datList[[currentDat]][['fieldNames']]())
datPrev
@@ -7,7 +7,7 @@
## Plotly or animit
## conditional calculated field: mutate and ddply; see documentation for ddply
## groups: use selectInput with multiple=T and selectize = F
## groups: use selectInput with multiple=TRUE and selectize = FALSE
## DONE: add sample data mtcars
## http://stackoverflow.com/questions/3418128/how-to-convert-a-factor-to-an-integer-numeric-without-a-loss-of-information
@@ -17,7 +17,7 @@
#options(error = browser)
options(shiny.error=NULL) # NULL
options(shiny.trace = F) # cahnge to T for trace
options(shiny.trace = FALSE) # change to TRUE for trace
#options(shiny.reactlog=TRUE)
require(shiny); require(reshape); require(ggplot2); require(Hmisc); require(uuid); require(plotly);
@@ -139,7 +139,7 @@ getAesChoices <- function(geom, stat='identity'){
)
}
AesChoicesSimpleList <- unique(unlist(lapply(GeomChoices, getAesChoices), use.names=F))
AesChoicesSimpleList <- unique(unlist(lapply(GeomChoices, getAesChoices), use.names=FALSE))
fonttable <- read.table(header=TRUE, sep=",", stringsAsFactors=FALSE,
text='
@@ -21,7 +21,7 @@ make.png <- function(obj, resolution=NULL) {
')
sink()
wd <- setwd(tempdir()); on.exit(setwd(wd))
texi2dvi(file=texFile, index=F)
texi2dvi(file=texFile, index=FALSE)
cmd <- paste("dvipng -T tight -o",
shQuote(pngFile),
@@ -34,7 +34,7 @@ make.png <- function(obj, resolution=NULL) {
}
newGuid <- function(){
gsub("-", "_", UUIDgenerate(), fixed=T)
gsub("-", "_", UUIDgenerate(), fixed=TRUE)
#paste(sample(c(letters[1:6],0:9),30,replace=TRUE),collapse="")
}
@@ -49,15 +49,15 @@ setdiff.c <<- function(x, y){
z
} else z
}
is.empty <<- function(x){
isEmpty <<- function(x){
is.null(x) || length(x)==0 || all(is.na(x)) || all(x=='')
}
ifnull <- function(x, d){
if(is.null(x)) d else x
}
ifempty <- function(x, d){
if(is.empty(x)) d else x
if(isEmpty(x)) d else x
}
null2String <- function(x){
@@ -82,7 +82,7 @@ convertSheetNameToDatName <- function(sheetName){
}
names2formula <- function(nms){
if(!is.empty(nms)){
if(!isEmpty(nms)){
paste(nms, collapse=" + ")
} else " . "
}
@@ -92,10 +92,10 @@ isFieldUninitialized <- function(obj, field){
}
are.vectors.different <- function(x, y){
if(is.empty(x)){
!is.empty(y)
if(isEmpty(x)){
!isEmpty(y)
} else {
is.empty(y) || any(x!=y)
isEmpty(y) || any(x!=y)
}
}
@@ -135,7 +135,7 @@ DatClass <- setRefClass("DatClass", fields=c("staticProperties","dynamicProperti
measureName <- 'MeasureNames'
moltenDat <<- reactive({
if(!is.empty(dynamicProperties[['measures']])){
if(!isEmpty(dynamicProperties[['measures']])){
melt(datR(), measure.vars=dynamicProperties[['measures']],
variable_name=measureName)
}
@@ -175,13 +175,13 @@ createNewLayer <- function(){
reactiveValues('geom'='point', 'statType'='identity', 'yFun'='sum', 'layerPositionType'='identity',
'activeAes'='aesX',
'aesList'=sapply(AesChoicesSimpleList,
function(x) reactiveValues('aesAggregate'=F,'aesDiscrete'=T,'aesMapOrSet'='map'), simplify=F))
function(x) reactiveValues('aesAggregate'=FALSE,'aesDiscrete'=TRUE,'aesMapOrSet'='map'), simplify=FALSE))
}
createNewSheetObj <- function(name='Sheet'){
SheetClass$new(
'dynamicProperties'=reactiveValues(
'name'=name,
'datId'='', 'combineMeasures'=F, 'outputType'='plot',
'datId'='', 'combineMeasures'=FALSE, 'outputType'='plot',
'columns'='', 'colChoices'='',
'rows'='', 'rowChoices'='',
'outputTable'=NULL,
View
@@ -1,5 +1,5 @@
source('helpers.r', local=T)
source('helpers.r', local=TRUE)
shinyServer(function(input, output, session) {
@@ -38,11 +38,11 @@ shinyServer(function(input, output, session) {
]][['layerList']][[currentLayer]][['aesList']][[currentAes]]
measures <- sheetList[[currentSheet]][['measuresR']]()
field <- aes[['aesField']]
if(is.empty(field)){
if(isEmpty(field)){
field <- sheetList[[currentSheet]][['dynamicProperties'
]][['layerList']][['Plot']][['aesList']][[currentAes]][['aesField']]
}
aes[['aesAggregate']] || (!is.empty(field) && field %in% measures)
aes[['aesAggregate']] || (!isEmpty(field) && field %in% measures)
})
})
}
@@ -72,7 +72,7 @@ shinyServer(function(input, output, session) {
if(isFieldUninitialized(sheetList[[currentSheet]],'layerNames')){
sheetList[[currentSheet]][['layerNames']] <<- reactive({
sl <- isolate(sheetList)
if(!is.empty(sl[[currentSheet]][['dynamicProperties']][['layerList']])){
if(!isEmpty(sl[[currentSheet]][['dynamicProperties']][['layerList']])){
names(sl[[currentSheet]][['dynamicProperties']][['layerList']])
} else c()
})
@@ -86,7 +86,7 @@ shinyServer(function(input, output, session) {
currentDat <- sl[[currentSheet]][['dynamicProperties']][['datId']]
combineMeasures <- sl[[currentSheet]][['dynamicProperties']][['combineMeasures']]
if(!is.empty(currentDat)){
if(!isEmpty(currentDat)){
currentDatObj <- dl[[currentDat]]
if(combineMeasures) currentDatObj[['moltenNames']]() else currentDatObj[['fieldNames']]()
}
@@ -100,7 +100,7 @@ shinyServer(function(input, output, session) {
currentDat <- sl[[currentSheet]][['dynamicProperties']][['datId']]
combineMeasures <- sl[[currentSheet]][['dynamicProperties']][['combineMeasures']]
if(!is.empty(currentDat)){
if(!isEmpty(currentDat)){
currentDatObj <- dl[[currentDat]]
if(combineMeasures) c(MoltenMeasuresName) else currentDatObj[['dynamicProperties']][['measures']]
}
@@ -114,7 +114,7 @@ shinyServer(function(input, output, session) {
currentDat <- sl[[currentSheet]][['dynamicProperties']][['datId']]
combineMeasures <- sl[[currentSheet]][['dynamicProperties']][['combineMeasures']]
if(!is.empty(currentDat)){
if(!isEmpty(currentDat)){
currentDatObj <- dl[[currentDat]]
if(combineMeasures) currentDatObj[['moltenDat']]() else currentDatObj[['datR']]()
}
@@ -152,7 +152,7 @@ shinyServer(function(input, output, session) {
cc <- empty2NULL(sl[[currentSheet]][['dynamicProperties']][['columns']])
rr <- empty2NULL(sl[[currentSheet]][['dynamicProperties']][['rows']])
datSheet <- sl[[currentSheet]][['datR']]()
validate(need(!is.empty(datSheet), label='Data'))
validate(need(!isEmpty(datSheet), label='Data'))
gg <- NULL
for(i in c('bar','line','point')) update_geom_defaults(i, list(colour = "darkblue", fill = "darkblue"))
@@ -170,7 +170,7 @@ shinyServer(function(input, output, session) {
if(!is.null(geom) && !is.null(stat) && !is.null(position)){
## get effective aesthetics taking into account of inheritance
aes.current <- layer.current[['aesList']][isolate(unlist(layer.current[['aesChoices']], use.names=F))]
aes.current <- layer.current[['aesList']][isolate(unlist(layer.current[['aesChoices']], use.names=FALSE))]
aes.current <- sapply(names(aes.current), function(n){
temp <- reactiveValuesToList(aes.current[[n]]) # converting to list so we can modify it
if(are.vectors.different(temp[['aesMapOrSet']],'set')){
@@ -183,7 +183,7 @@ shinyServer(function(input, output, session) {
}
}
temp
}, simplify=F)
}, simplify=FALSE)
aes.current <- aes.current[sapply(aes.current,
function(x) !are.vectors.different(x[['aesMapOrSet']],'set') || !is.null(x[['aesField']]))]
@@ -246,7 +246,7 @@ shinyServer(function(input, output, session) {
# some validation
agg.fields <- sapply(aes.toAgg, function(x) x[['aesFieldOriginal']])
overlaps <- intersect(agg.fields, c(rr,cc))
validate(need(is.empty(overlaps), 'Can not aggregate fields used in faceting.'))
validate(need(isEmpty(overlaps), 'Can not aggregate fields used in faceting.'))
# build the call for ddply
.args <- lapply(aes.toAgg, function(x) parse(text=paste(x[['aesAggFun']], '(', x[['aesFieldOriginal']], ')', sep=''))[[1]])
@@ -338,7 +338,7 @@ shinyServer(function(input, output, session) {
}
}
if(!is.null(gg)){
if(!is.empty(cc) || !is.empty(rr)){
if(!isEmpty(cc) || !isEmpty(rr)){
gg <- gg + facet_grid(as.formula(paste(names2formula(rr), names2formula(cc), sep=" ~ ")))
}
gg <- gg + theme_bw()
@@ -357,13 +357,13 @@ shinyServer(function(input, output, session) {
gg <- sl[[currentSheet]][['plotCore']]()
if(!is.null(gg)){
if(!is.empty(aes.base[['aesX']][['aesField']])){
if(!isEmpty(aes.base[['aesX']][['aesField']])){
i.match <- match(aes.base[['aesX']][['aesField']], fieldNames)
if(!is.na(i.match)){
gg <- gg + xlab(names(fieldNames)[i.match])
}
}
if(!is.empty(aes.base[['aesY']][['aesField']])){
if(!isEmpty(aes.base[['aesY']][['aesField']])){
i.match <- match(aes.base[['aesY']][['aesField']], fieldNames)
if(!is.na(i.match)){
gg <- gg + ylab(names(fieldNames)[i.match])
@@ -390,20 +390,20 @@ shinyServer(function(input, output, session) {
isDatBasedonSheet <- function(datId, sheetId){
if(!is.null(datList[[datId]])){
while(datList[[datId]][['staticProperties']][['type']] == 'sheet'){
if(datId==sheetId) return(T)
if(datId==sheetId) return(TRUE)
datId <- sheetList[[datId]][['dynamicProperties']][['datId']]
}
}
F
FALSE
}
source('data.r', local=T)
source('sheets.r', local=T)
source('project.r', local=T)
source('data.r', local=TRUE)
source('sheets.r', local=TRUE)
source('project.r', local=TRUE)
})
Oops, something went wrong.

0 comments on commit 2557fb7

Please sign in to comment.