code
stringlengths
1
13.8M
HSC_PC_None <- function() { structure(list(),class = c("HSC_PC_None","HSC_PC")) } classify.HSC_PC_None <- function(x, stream, ...) { if(!".clazz" %in% colnames(stream)) stop("HSC_PC none: .clazz field not found in the input stream") res <- data.frame(stream,stringsAsFactors=FALSE) return(res) }
optimizeStrata <- function (errors, strata, cens = NULL, strcens = FALSE, alldomains = TRUE, dom = NULL, initialStrata = NA, addStrataFactor = 0, minnumstr = 2, iter = 50, pops = 20, mut_chance = NA, elitism_rate = 0.2, highvalue = 1e+08, suggestions = NULL, realAllocation = TRUE, writeFiles = FALSE, showPlot = TRUE, parallel = TRUE, cores = NA) { if (writeFiles == TRUE) { dire <- getwd() direnew <- paste(dire, "/output", sep = "") if (dir.exists(direnew)) unlink(direnew,recursive=TRUE) if (!dir.exists(direnew)) dir.create(direnew) } if(parallel == FALSE & !missing(cores) | !is.na(cores)){ cat("Sequential optimization as parallel = FALSE, defaulting number of cores = 1") cores <- 1 Sys.sleep(0.314) } if (is.na(initialStrata[1])) initialStrata <- as.numeric(table(strata$DOM1)) nstrata = initialStrata colnames(errors) <- toupper(colnames(errors)) colnames(strata) <- toupper(colnames(strata)) errors$DOMAINVALUE <- as.factor(errors$DOMAINVALUE) erro <- split(errors, list(errors$DOMAINVALUE)) stcamp <- split(strata, list(strata$DOM1)) if (!is.null(suggestions)) suggestdom <- split(suggestions, list(suggestions$domainvalue)) if (strcens == TRUE) { colnames(cens) <- toupper(colnames(cens)) k <- length(levels(as.factor(strata$DOM1))) stcens <- NULL for (i in (1:k)) { stcens[[i]] <- cens[cens$DOM1 == i, ] } } ndom <- length(levels(as.factor(strata$DOM1))) if (alldomains == TRUE) { if (ndom > length(nstrata)) stop("'initialStrata' vector lenght (=", length(nstrata), ") \nis not compatible with number of domains (=", ndom, ")\nSet initialStrata with a number of elements equal to the number of domains") vettsol <- NULL outstrata <- NULL if (parallel == TRUE & ndom == 1) parallel <- FALSE if (parallel) { if (missing(cores) | is.na(cores)) { cores <- parallel::detectCores() - 1 if (ndom < cores) cores <- ndom } if (cores < 2) stop("\nOnly one core available: no parallel processing possible. \nPlease change parameter parallel = FALSE and run again") cat("\n *** Starting parallel optimization for ", ndom, " domains using ", cores, " cores\n") cl <- parallel::makePSOCKcluster(cores) doParallel::registerDoParallel(cl) on.exit(parallel::stopCluster(cl)) parallel::clusterExport(cl = cl, ls(), envir = environment()) showPlot <- FALSE par_ga_sol = pblapply( cl = cl, X = unique(strata$DOM1), FUN = function(i) { erro[[i]] <- erro[[i]][, -ncol(errors)] cens <- NULL flagcens <- strcens if (strcens == TRUE) { if (nrow(stcens[[i]]) > 0) { cens <- stcens[[i]] flagcens = TRUE } } if (strcens == TRUE) { if (nrow(stcens[[i]]) == 0) { cens <- NULL flagcens = FALSE } } if (strcens == FALSE) { cens <- NULL flagcens = FALSE } if (!is.null(suggestions) & alldomains == TRUE) { suggest <- matrix(0, nrow = 1, ncol = nrow(stcamp[[i]])) suggest[1, ] <- suggestdom[[i]]$suggestions } if (!is.null(suggestions) & alldomains == FALSE) { suggest <- matrix(0, nrow = 1, ncol = nrow(stcamp[[i]])) suggest[1, ] <- suggestions$suggestions } if (is.null(suggestions)) { suggest <- NULL } if (nrow(stcamp[[i]]) > 0) { solut <- strataGenalg(errors = erro[[i]], strata = stcamp[[i]], cens = cens, strcens = flagcens, dominio = i, initialStrata = nstrata[i], minnumstr, iter, pops, mut_chance, elitism_rate, addStrataFactor, highvalue, suggestions = suggest, realAllocation, writeFiles, showPlot) if (nrow(stcamp[[i]]) == 1) { solut <- list(c(1), stcamp[[i]][c(1:grep("DOM1", colnames(stcamp[[i]])))]) error <- data.frame(erro[[i]],stringsAsFactors = TRUE) strat <- data.frame(solut[[2]],stringsAsFactors = TRUE) solut[[2]]$SOLUZ <- sum(bethel(strat, error, realAllocation = T)) if (solut[[2]]$SOLUZ > solut[[2]]$N) solut[[2]]$SOLUZ <- solut[[2]]$N } vettsol <- solut[[1]] if (length(outstrata) > 0) colnames(outstrata) <- toupper(colnames(outstrata)) colnames(solut[[2]]) <- toupper(colnames(solut[[2]])) outstrata <- solut[[2]] rbga.results <- solut[[3]] list(vettsol = vettsol, outstrata = outstrata, rbga.results = rbga.results) } } ) vettsol <- do.call(c, lapply(par_ga_sol, `[[`, 1)) outstrata <- do.call(rbind, lapply(par_ga_sol, `[[`, 2)) for (i in (unique(strata$DOM1))) { rbga.object <- par_ga_sol[[i]]$rbga.results max <- max(rbga.object$best, rbga.object$mean) min <- min(rbga.object$best, rbga.object$mean) if (writeFiles == TRUE) { stmt <- paste("png(filename = file.path(direnew, 'plotdom", i, ".png'),height=5, width=7, units='in', res=144)", sep = "") eval(parse(text = stmt)) } plot(rbga.object$best, type = "l", main = "", ylim = c(min,max), xlab = "Iteration (Generation)", ylab = "Best (black lower line) and mean (red upper line) evaluation value") lines(rbga.object$mean, col = "red") title(paste("Domain round(min(rbga.object$best), 2)), col.main = "red") if (writeFiles == TRUE) dev.off() } } else { for (i in (unique(strata$DOM1))) { cat("\n *** Domain : ", i, " ", as.character(errors$DOMAINVALUE[i])) cat("\n Number of strata : ", nrow(stcamp[[i]])) erro[[i]] <- erro[[i]][, -ncol(errors)] cens <- NULL flagcens <- strcens if (strcens == TRUE) { if (nrow(stcens[[i]]) > 0) { cens <- stcens[[i]] flagcens = TRUE } } if (strcens == TRUE) { if (nrow(stcens[[i]]) == 0) { cens <- NULL flagcens = FALSE } } if (strcens == FALSE) { cens <- NULL flagcens = FALSE } if (!is.null(suggestions) & alldomains == TRUE) { suggest <- matrix(0, nrow = 1, ncol = nrow(stcamp[[i]])) suggest[1, ] <- suggestdom[[i]]$suggestions } if (!is.null(suggestions) & alldomains == FALSE) { suggest <- matrix(0, nrow = 1, ncol = nrow(stcamp[[i]])) suggest[1, ] <- suggestions$suggestions } if (is.null(suggestions)) { suggest <- NULL } if (nrow(stcamp[[i]]) > 0) { solut <- strataGenalg(errors = erro[[i]], strata = stcamp[[i]], cens = cens, strcens = flagcens, dominio = i, initialStrata = nstrata[i], minnumstr, iter, pops, mut_chance, elitism_rate, addStrataFactor, highvalue, suggestions = suggest, realAllocation, writeFiles, showPlot) if (nrow(stcamp[[i]]) == 1) { solut <- list(c(1), stcamp[[i]][c(1:grep("DOM1", colnames(stcamp[[i]])))]) error <- data.frame(erro[[i]],stringsAsFactors = TRUE) strat <- data.frame(solut[[2]],stringsAsFactors = TRUE) solut[[2]]$SOLUZ <- sum(bethel(strat, error, realAllocation = T)) if (solut[[2]]$SOLUZ > solut[[2]]$N) solut[[2]]$SOLUZ <- solut[[2]]$N } vettsol <- c(vettsol, solut[[1]]) if (length(outstrata) > 0) colnames(outstrata) <- toupper(colnames(outstrata)) colnames(solut[[2]]) <- toupper(colnames(solut[[2]])) outstrata <- rbind(outstrata, solut[[2]]) rbga.object <- solut[[3]] max <- max(rbga.object$best, rbga.object$mean) min <- min(rbga.object$best, rbga.object$mean) if (writeFiles == TRUE) { stmt <- paste("png(filename = file.path(direnew, 'plotdom", i, ".png'),height=5, width=7, units='in', res=144)", sep = "") eval(parse(text = stmt)) } plot(rbga.object$best, type = "l", main = "", ylim = c(min,max), xlab = "Iteration (Generation)", ylab = "Best (black lower line) and mean (red upper line) evaluation value") lines(rbga.object$mean, col = "red") title(paste("Domain round(min(rbga.object$best), 2)), col.main = "red") if (writeFiles == TRUE) dev.off() } } } } if (alldomains == FALSE) { if (dom < 1 | dom > ndom) stop("\nInvalid value of the indicated domain\n") i <- dom erro[[i]] <- erro[[i]][, -ncol(errors)] flagcens <- strcens if (strcens == TRUE) { flagcens <- TRUE colnames(cens) <- toupper(colnames(cens)) censi <- cens[cens$DOM1 == i, ] if (nrow(censi) == 0) { flagcens <- FALSE censi <- NULL } } if (!is.null(suggestions) & alldomains == TRUE) { suggest <- matrix(0, nrow = 1, ncol = nrow(stcamp[[i]])) suggest[1, ] <- suggestdom[[i]]$suggestions } if (!is.null(suggestions) & alldomains == FALSE) { suggest <- matrix(0, nrow = 1, ncol = nrow(stcamp[[i]])) suggest[1, ] <- suggestdom[[dom]]$suggestions } if (is.null(suggestions)) { suggest <- NULL } solut <- strataGenalg(errors = erro[[i]], strata = stcamp[[i]], cens = censi, strcens = flagcens, dominio = i, initialStrata = nstrata[i], minnumstr, iter, pops, mut_chance, elitism_rate, addStrataFactor, highvalue, suggestions = suggest, realAllocation, writeFiles, showPlot) vettsol <- solut[[1]] outstrata <- solut[[2]] rbga.object <- solut[[3]] if (writeFiles == TRUE) { stmt <- paste("png(filename = file.path(direnew, 'plotdom",dom,".png'),height=5, width=7, units='in', res=144)", sep = "") eval(parse(text = stmt)) } max <- max(rbga.object$best, rbga.object$mean) min <- min(rbga.object$best, rbga.object$mean) plot(rbga.object$best, type = "l", main = "", ylim = c(min,max), xlab = "Iteration (Generation)", ylab = "Best (black lower line) and mean (red upper line) evaluation value") lines(rbga.object$mean, col = "red") title(paste("Domain round(min(rbga.object$best), 2)), col.main = "red") if (writeFiles == TRUE) dev.off() } colnames(outstrata) <- toupper(colnames(outstrata)) dimens <- sum(round(outstrata$SOLUZ)) cat("\n *** Sample size : ", dimens) cat("\n *** Number of strata : ", nrow(outstrata)) cat("\n---------------------------") if (writeFiles == TRUE) { write.table(outstrata, file = file.path(direnew, "outstrata.txt"), sep = "\t", row.names = FALSE, col.names = TRUE, quote = FALSE) cat("\n...written output to ", direnew,"/outstrata.txt\n") } solution <- list(indices = vettsol, aggr_strata = outstrata) if (writeFiles == TRUE) { setwd(dire) } return(solution) }
R2.lik <- function(mod = NULL, mod.r = NULL) { if (class(mod)[1] == "merModLmerTest") class(mod) <- "lmerMod" if (!is.element(class(mod)[1], c("lm", "glm", "lmerMod", "glmerMod", "phylolm", "phyloglm", "gls", "communityPGLMM"))) { stop("mod must be class one of classes lm, glm, lmerMod, glmerMod, phylolm, phyloglm, gls, communityPGLMM.") } if (class(mod)[1] == "lm") { if (!is.object(mod.r)) { y <- model.frame(mod)[, 1] mod.r <- lm(y ~ 1) } if (!is.element(class(mod.r)[1], c("lm"))) { stop("mod.r must be class lm.") } return(R2.lik.lm(mod, mod.r)[1]) } if (class(mod)[1] == "glm") { if (!is.object(mod.r)) { y <- model.frame(mod)[, 1] mod.r <- glm(y ~ 1, family = family(mod)[[1]]) } if (!is.element(class(mod.r)[1], c("glm"))) { stop("mod.r must be class glm.") } if (family(mod)[[1]] != family(mod.r)[[1]]) { stop("Sorry, but mod and mod.r must be from the same family of distributions.") } return(R2.lik.glm(mod, mod.r)[1]) } if (class(mod)[1] == "lmerMod") { if (!is.object(mod.r)) { y <- model.frame(mod)[, 1] mod.r <- lm(y ~ 1) } if (class(mod.r)[1] == "merModLmerTest") class(mod.r) <- "lmerMod" if (!is.element(class(mod.r)[1], c("lmerMod", "lm"))) { stop("mod.r must be class lmerMod or lm.") } if (lme4::isREML(mod)) { mod <- update(mod, REML = F) warning("mod updated with REML = F") } if (class(mod.r)[1] == "lmerMod" && lme4::isREML(mod.r)) { mod.r <- update(mod.r, REML = F) warning("mod.r updated with REML = F") } return(R2.lik.lmerMod(mod, mod.r)[1]) } if (class(mod)[1] == "glmerMod") { if (!is.object(mod.r)) { y <- model.frame(mod)[, 1] mod.r <- glm(y ~ 1, family = family(mod)[[1]]) } if (!is.element(class(mod.r)[1], c("glmerMod", "glm"))) { stop("mod.r must be class glmerMod or glm.") } if (family(mod)[[1]] != family(mod.r)[[1]]) { stop("Sorry, but mod and mod.r must be from the same family of distributions.") } return(R2.lik.glmerMod(mod, mod.r)[1]) } if (class(mod)[1] == "phylolm") { if (!is.object(mod.r)) { y <- mod$y mod.r <- lm(y ~ 1) } if (!is.element(class(mod.r)[1], c("phylolm", "lm"))) { stop("mod.r must be class phylolm or lm.") } return(R2.lik.phylolm(mod, mod.r)) } if (class(mod)[1] == "phyloglm") { if (!is.object(mod.r)) { y <- mod$y mod.r <- glm(y ~ 1, family = "binomial") } if (!is.element(class(mod.r)[1], c("phyloglm", "glm"))) { stop("mod.r must be class phyloglm or glm.") } return(R2.lik.phyloglm(mod, mod.r)[1]) } if (class(mod)[1] == "gls") { if (!is.object(mod.r)) { y <- as.numeric(fitted(mod) + resid(mod)) mod.r <- lm(y ~ 1) } if (!is.element(class(mod.r)[1], c("gls", "lm"))) { stop("mod.r must be class gls or lm.") } return(R2.lik.gls(mod, mod.r)) } if (class(mod)[1] == "communityPGLMM") { if (mod$family == "binomial") stop("Binary communityPGLMMs do not have log likelihood, If you are interested in LRT of random terms, use phyr::communityPGLMM.binary.LRT()") if (mod$REML == TRUE) stop("mod was fitted with REML, please set it to FALSE and re-fit it") if (!is.object(mod.r)) { y <- mod$Y mod.r <- lm(y ~ 1) } if (!is.element(class(mod.r)[1], c("communityPGLMM", "lm"))) { stop("mod.r must be class communityPGLMM or lm.") } return(R2.like.communityPGLMM(mod, mod.r)) } } R2.lik.lm <- function(mod = NULL, mod.r = NULL) { X <- model.matrix(mod) n <- dim(X)[1] R2.lik <- 1 - exp(-2/n * (logLik(mod)[[1]] - logLik(mod.r)[[1]])) return(R2.lik) } R2.lik.glm <- R2.lik.lm R2.lik.lmerMod <- R2.lik.lm R2.lik.glmerMod <- function(mod = NULL, mod.r = NULL) { X <- model.matrix(mod) n <- dim(X)[1] R2.lik <- (1 - exp(-2/n * (logLik(mod) - logLik(mod.r))))/(1 - exp(2/n * logLik(mod.r))) return(R2.lik) } R2.lik.phylolm <- function(mod = NULL, mod.r = NULL) { X <- mod$X n <- dim(X)[1] R2.lik <- 1 - exp(-2/n * (logLik(mod)[[1]] - logLik(mod.r)[[1]])) return(R2.lik) } R2.lik.phyloglm <- function(mod = NULL, mod.r = NULL) { y <- mod$y X <- mod$X n <- dim(X)[1] alpha.cutoff <- 50 if (mod$alpha < alpha.cutoff) { LL <- mod$logLik } else { LL <- logLik(glm(y ~ 0 + X, family = "binomial")) warning("In mod, estimate of alpha >50, so model refit with glm()") } if (class(mod.r)[1] == "phyloglm") { if (mod.r$alpha < alpha.cutoff) { LL.r <- mod.r$logLik } else { X.r <- mod.r$X LL.r <- logLik(glm(y ~ 0 + X.r, family = "binomial")) warning("In mod.r, estimate of alpha >50, so model refit with glm()") } } else { LL.r <- logLik(mod.r) } R2.lik <- (1 - exp(-2/n * (LL - LL.r)))/(1 - exp(2/n * LL.r)) return(R2.lik) } R2.lik.gls <- function(mod = NULL, mod.r = NULL) { n <- mod$dims$N R2.lik <- 1 - exp(-2/n * (logLik(mod)[[1]] - logLik(mod.r)[[1]])) return(R2.lik) } R2.like.communityPGLMM <- function(mod = NULL, mod.r = NULL) { n <- nrow(mod$X) if (class(mod.r) == "lm") { ll.r <- logLik(mod.r)[[1]] } else { ll.r <- mod.r$logLik } R2.lik <- 1 - exp(-2/n * (mod$logLik - ll.r)) return(R2.lik) }
svglite <- function(filename = "Rplot%03d.svg", width = 10, height = 8, bg = "white", pointsize = 12, standalone = TRUE, system_fonts = list(), user_fonts = list(), web_fonts = list(), id = NULL, fix_text_size = TRUE, scaling = 1, always_valid = FALSE, file) { if (!missing(file)) { filename <- file } if (invalid_filename(filename)) stop("invalid 'file': ", filename) aliases <- validate_aliases(system_fonts, user_fonts) web_fonts <- validate_web_fonts(web_fonts) if (is.null(id)) { id <- character(0) } id <- as.character(id) invisible(svglite_(filename, bg, width, height, pointsize, standalone, aliases, web_fonts, id, fix_text_size, scaling, always_valid)) } svgstring <- function(width = 10, height = 8, bg = "white", pointsize = 12, standalone = TRUE, system_fonts = list(), user_fonts = list(), web_fonts = list(), id = NULL, fix_text_size = TRUE, scaling = 1) { aliases <- validate_aliases(system_fonts, user_fonts) web_fonts <- validate_web_fonts(web_fonts) if (is.null(id)) { id <- character(0) } id <- as.character(id) env <- new.env(parent = emptyenv()) string_src <- svgstring_(env, width = width, height = height, bg = bg, pointsize = pointsize, standalone = standalone, aliases = aliases, webfonts = web_fonts, id = id, fix_text_size, scaling) function() { svgstr <- env$svg_string if(!env$is_closed) { svgstr <- c(svgstr, get_svg_content(string_src)) } structure(svgstr, class = "svg") } } print.svg <- function(x, ...) cat(x, sep = "\n")
runGlmnet=function( x, y, nPredics, family="gaussian", nfolds=10, lambda.min.ratio=0.05, nLam=100, standardize=FALSE, intercept=TRUE, zeroSDCut=0 ){ results=list() nBeta=ncol(x) nObsAll=length(y) sdX=apply(x,2,sd) xWithNearZeroSd=which(sdX<=zeroSDCut) if(length(xWithNearZeroSd)>0){ x=x[,-xWithNearZeroSd,drop=FALSE] } rm(sdX) if(family=="gaussian"){lamMax=max(abs(Matrix::colSums(x*y)))/nObsAll} lamVec=seq(lamMax,0,length=(nLam+1))[1:nLam] cvStartTime= proc.time()[3] cvStartTimei = proc.time()[3] cvResul=cv.glmnet(x=x,y=as.vector(y),lambda=lamVec,nfolds=nfolds, family=family,intercept=intercept,standardize=standardize) cvExeTimei= (proc.time()[3] - cvStartTimei)/60 lamOpi=as.numeric(cvResul$lambda.min) cvm=as.vector(cvResul$cvm)*nObsAll nLamUsed=length(as.vector(cvResul$lambda)) rm(cvResul) cvAllTime= (proc.time()[3] - cvStartTime)/60 results$lamList=lamVec rm(lamVec) results$lambda=lamOpi rm(lamOpi) finalLassoRun=glmnet(x=x,y=as.vector(y),lambda=results$lambda,family=family, intercept=intercept,standardize=standardize) rm(x,y) finalLassoRunBeta=as.vector(finalLassoRun$beta) if(length(xWithNearZeroSd)>0){ betaTrans=groupBetaToFullBeta(nTaxa=nBeta,nPredics=1, unSelectList=sort(xWithNearZeroSd),newBetaNoInt=finalLassoRunBeta) beta=betaTrans$finalBeta rm(betaTrans) rm(xWithNearZeroSd) } else { beta=finalLassoRunBeta } rm(finalLassoRun) results$betaNoInt=beta[-seq(1,length(beta),by=(nPredics+1))] results$betaInt=beta rm(beta) results$SSE=cvm rm(cvm) return(results) }
sortA <- function(blk, At, C, b, X0, Z0, spdensity=NULL, smallblkdim=NULL){ if(length(get("spdensity", pos=sys.frame(which = -2))) > 0){ spdensity <- get("spdensity", pos=sys.frame(which = -2)) }else{ assign("spdensity",0.4, pos=sys.frame(which = -2)) } if(length(get("smallblkdim", pos=sys.frame(which = -2))) > 0){ smallblkdim <- get("smallblkdim", pos=sys.frame(which = -2)) }else{ assign("smallblkdim",50, pos=sys.frame(which = -2)) } numblk <- nrow(blk) m <- length(b) nnzA <- matrix(0,numblk,m) permA <- kronecker(matrix(1,numblk,1),matrix(c(1:m), nrow=1)) permZ <- matrix(list(),nrow=nrow(blk), ncol=1) for(p in 1:nrow(blk)){ n <- sum(blk[[p,2]]) numblk <- length(blk[[p,2]]) if(blk[[p,1]] == "s" & max(blk[[p,2]]) > smallblkdim){ n2 <- sum(blk[[p,2]]*blk[[p,2]]) n22 <- sum(blk[[p,2]]*(blk[[p,2]] + 1))/2 m1 <- ncol(At[[p,1]]) if(is.null(m1)){ m1 <- 0 } if(length(blk[[p,2]]) == 1){ tmp <- abs(C[[p,1]]) + abs(Z0[[p,1]]) if(length(At[[p,1]]) > 0){ tmp <- tmp + smat(blk[p,,drop=FALSE],p,abs(At[[p,1]]) %*% matrix(1,m1,1),0) } if(length(which(tmp != 0)) < spdensity*n22){ per <- symamdR(tmp) invper <- rep(0,n) invper[per] <- 1:n permZ[[p,1]] <- invper if(length(At[[p,1]]) > 0){ isspAt <- is(At[[p,1]], 'sparseMatrix') for(k in 1:m1){ Ak <- smat(blk[p,,drop=FALSE],p,At[[p,1]][,k],0) At[[p,1]][,k] <- svec(blk[p,,drop=FALSE],Ak[per,per],isspAt) } } C[[p,1]] <- C[[p,1]][per,per] Z0[[p,1]] <- Z0[[p,1]][per,per] X0[[p,1]] <- X0[[p,1]][per,per] }else{ per <- c() } if(ncol(blk) > 2 & length(per) > 0){ m2 <- length(blk[[p,3]]) P <- matrix(0,n,max(per)) for(i in 1:n){ P[i,per[i]] <- 1 } At[[p,2]] <- P %*% At[[p,2]] } } if(length(At[[p,1]]) > 0 & mexnnz(At[[p,1]]) < m*n22/2){ for(k in 1:m1){ Ak <- At[[p,1]][,k] nnzA[p,k] <- length(which(abs(Ak) > 2.2204e-16)) } permAp <- order(nnzA[p,1:m1]) At[[p,1]] <- At[[p,1]][,permAp] permA[p,1:m1] <- permAp } }else if(blk[[p,1]] == "q" | blk[[p,1]] == "l" | blk[[p,1]] == "u"){ if(!is(At[[p,1]], 'sparseMatrix')){ At[[p,1]] <- Matrix(At[[p,1]], sparse=TRUE) } } } return(list(At=At, C=C, X=X0, Z=Z0, permA = permA, permZ=permZ)) }
observe({ tryCatch({ all_ids <- get_workflow_ids(dbConnect$bety, query, all.ids=TRUE) selectList <- as.data.table(all_ids) updateSelectizeInput(session, "all_workflow_id", choices = all_ids, server = TRUE) query <- parseQueryString(session$clientData$url_search) if(length(query)>0) updateSelectizeInput(session, "all_workflow_id", selected = query[["workflow_id"]]) toastr_success("Update workflow IDs") }, error = function(e) { toastr_error(title = "Error", conditionMessage(e)) }) }) all_run_ids <- reactive({ req(input$all_workflow_id) w_ids <- input$all_workflow_id run_id_list <- c() for(w_id in w_ids){ r_ids <- get_run_ids(dbConnect$bety, w_id) for(r_id in r_ids){ list_item <- paste0('workflow ', w_id,', run ', r_id) run_id_list <- c(run_id_list, list_item) } } return(run_id_list) }) observeEvent(input$all_workflow_id,{ tryCatch({ updateSelectizeInput(session, "all_run_id", choices = all_run_ids()) query <- parseQueryString(session$clientData$url_search) url_run_id <- paste0('workflow ', query[["workflow_id"]],', run ', query[["run_id"]]) updateSelectizeInput(session, "all_run_id", selected = url_run_id) toastr_success("Update run IDs") }, error = function(e) { toastr_error(title = "Error", conditionMessage(e)) }) }) load.model <- eventReactive(input$load_model,{ req(input$all_run_id) ids_DF <- parse_ids_from_input_runID(input$all_run_id) globalDF <- map2_df(ids_DF$wID, ids_DF$runID, ~tryCatch({ load_data_single_run(dbConnect$bety, .x, .y) }, error = function(e){ toastr_error(title = paste("Error in WorkflowID", .x), conditionMessage(e)) return() })) print("Yay the model data is loaded!") print(head(globalDF)) globalDF$var_name <- as.character(globalDF$var_name) globalDF$run_id <- as.factor(as.character(globalDF$run_id)) return(globalDF) }) observeEvent(input$load_model, { req(input$all_run_id) ids_DF <- parse_ids_from_input_runID(input$all_run_id) var_name_list <- c() for(row_num in 1:nrow(ids_DF)){ var_name_list <- c(var_name_list, tryCatch({ var_names_all(dbConnect$bety, ids_DF$wID[row_num], ids_DF$runID[row_num]) }, error = function(e){ return(NULL) })) } updateSelectizeInput(session, "var_name_model", choices = var_name_list) }) observeEvent(input$load_model,{ req(input$all_run_id) ids_DF <- parse_ids_from_input_runID(input$all_run_id) site_id_list <- c() for(row_num in 1:nrow(ids_DF)){ settings <- tryCatch({ getSettingsFromWorkflowId(dbConnect$bety,ids_DF$wID[row_num]) }, error = function(e){ return(NULL) }) site.id <- c(settings$run$site$id) site_id_list <- c(site_id_list,site.id) } updateSelectizeInput(session, "all_site_id", choices=site_id_list) }) observe({ req(input$all_site_id) inputs_df <- getInputs(dbConnect$bety, c(input$all_site_id)) formats_1 <- dplyr::tbl(dbConnect$bety, 'formats_variables') %>% dplyr::filter(format_id %in% inputs_df$format_id) if (dplyr.count(formats_1) == 0) { logger.warn("No inputs found. Returning NULL.") return(NULL) } else { formats_sub <- formats_1 %>% dplyr::pull(format_id) %>% unique() inputs_df <- inputs_df %>% dplyr::filter(format_id %in% formats_sub) updateSelectizeInput(session, "all_input_id", choices=inputs_df$input_selection_list) } }) load.model.data <- eventReactive(input$load_data, { req(input$all_input_id) inputs_df <- getInputs(dbConnect$bety,c(input$all_site_id)) inputs_df <- inputs_df %>% dplyr::filter(input_selection_list == input$all_input_id) input_id <- inputs_df$input_id File_format <- PEcAn.DB::query.format.vars(bety = dbConnect$bety, input.id = input_id) start.year <- as.numeric(lubridate::year(inputs_df$start_date)) end.year <- as.numeric(lubridate::year(inputs_df$end_date)) File_path <- inputs_df$filePath site.id <- inputs_df$site_id site <- PEcAn.DB::query.site(site.id,dbConnect$bety) observations <- PEcAn.benchmark::load_data( data.path = File_path, format = File_format, time.row = File_format$time.row, site = site, start_year = start.year, end_year = end.year) print("Yay the observational data is loaded!") print(head(observations)) return(observations) }) observeEvent(input$load_data, { tryCatch({ withProgress(message = 'Calculation in progress', detail = 'This may take a while...', value = 0,{ model.df <- load.model() incProgress(7 / 15) obvs.df <- load.model.data() incProgress(7 / 15) updateSelectizeInput(session, "var_name_modeldata", choices = intersect(model.df$var_name, names(obvs.df))) incProgress(1 / 15) }) toastr_success("Update variable names") }, error = function(e) { toastr_error(title = "Error", conditionMessage(e)) }) }) volumes <- c(Home = fs::path_home(), "R Installation" = R.home(), getVolumes()()) shinyDirChoose(input, "regdirectory", roots = volumes, session = session, restrictions = system.file(package = "base")) output$formatPreview <- DT::renderDT({ req(input$format_sel_pre) tryCatch({ Fids <- PEcAn.DB::get.id("formats", "name", input$format_sel_pre, dbConnect$bety) %>% as.character() if (length(Fids) > 1) toastr_warning(title = "Format Preview", message = "More than one id was found for this format. The first one will be used.") mimt<-tbl(dbConnect$bety, "formats") %>% left_join(tbl(dbConnect$bety, "mimetypes"), by=c('mimetype_id'='id'))%>% dplyr::filter(id==Fids[1]) %>% dplyr::pull(type_string) output$mimt_pre<-renderText({ mimt }) DT::datatable( tbl(dbConnect$bety, "formats_variables") %>% dplyr::filter(format_id == Fids[1]) %>% dplyr::select(-id, -format_id,-variable_id,-created_at,-updated_at) %>% dplyr::filter(name != "") %>% collect(), escape = F, filter = 'none', selection = "none", style = 'bootstrap', rownames = FALSE, options = list( autowidth = TRUE, columnDefs = list(list( width = '90px', targets = -1 )), dom = 'tp', pageLength = 10, scrollX = TRUE, scrollCollapse = FALSE, initComplete = DT::JS( "function(settings, json) {", "$(this.api().table().header()).css({'background-color': ' "}" ) ) ) }, error = function(e) { toastr_error(title = "Error in format preview", message = conditionMessage(e)) }) }) observeEvent(input$register_data,{ req(input$all_site_id) showModal( modalDialog( title = "Register External Data", tabsetPanel( tabPanel("Register", br(), fluidRow( column(6, fileInput("Datafile", "Choose CSV/NC File", width = "100%", accept = c( "text/csv", "text/comma-separated-values,text/plain", ".csv", ".nc") )), column(6,br(), shinyFiles::shinyDirButton("regdirectory", "Choose your target dir", "Please select a folder") ), tags$hr() ), fluidRow( column(6, dateInput("date3", "Start Date:", value = Sys.Date()-10)), column(6, dateInput("date4", "End Date:", value = Sys.Date()-10) ) ),tags$hr(), fluidRow( column(6, shinyTime::timeInput("time2", "Start Time:", value = Sys.time())), column(6, shinyTime::timeInput("time2", "End Time:", value = Sys.time())) ),tags$hr(), fluidRow( column(6, selectizeInput("format_sel", "Format Name", tbl(dbConnect$bety,"formats") %>% pull(name) %>% unique() ) ), column(6) ) ), tabPanel("Fromat Preview", br(), fluidRow( column(6,selectizeInput("format_sel_pre", "Format Name", tbl(dbConnect$bety,"formats") %>% pull(name) %>% unique())), column(6, h5(shiny::tags$b("Mimetypes")), textOutput("mimt_pre")) ), fluidRow( column(12, DT::dataTableOutput("formatPreview") ) ) ) ), footer = tagList( actionButton("register_button", "Register", class="btn-primary"), modalButton("Cancel") ), size = 'l' ) ) }) observeEvent(input$register_button,{ tryCatch({ inFile <- input$Datafile dir.name <- gsub(".[a-z]+", "", inFile$name) dir.create(file.path(parseDirPath(volumes, input$regdirectory), dir.name)) file.copy(inFile$datapath, file.path(parseDirPath(volumes, input$regdirectory), dir.name, inFile$name), overwrite = T) mt <- tbl(dbConnect$bety,"formats") %>% left_join(tbl(dbConnect$bety,"mimetypes"), by = c("mimetype_id" = "id")) %>% filter(name == input$format_sel) %>% pull(type_string) PEcAn.DB::dbfile.input.insert(in.path = file.path(parseDirPath(volumes, input$regdirectory), dir.name), in.prefix = inFile$name, siteid = input$all_site_id, startdate = input$date3, enddate = input$date4, mimetype = mt, formatname = input$format_sel, con = dbConnect$bety ) removeModal() toastr_success("Register External Data") }, error = function(e){ toastr_error(title = "Error", conditionMessage(e)) }) }) observeEvent(input$register_button,{ req(input$all_site_id) inputs_df <- getInputs(dbConnect$bety, c(input$all_site_id)) formats_1 <- dplyr::tbl(dbConnect$bety, 'formats_variables') %>% dplyr::filter(format_id %in% inputs_df$format_id) if (dplyr.count(formats_1) == 0) { logger.warn("No inputs found. Returning NULL.") return(NULL) } else { formats_sub <- formats_1 %>% dplyr::pull(format_id) %>% unique() inputs_df <- inputs_df %>% dplyr::filter(format_id %in% formats_sub) updateSelectizeInput(session, "all_input_id", choices=inputs_df$input_selection_list) } })
testthat::context("Unit tests for impact_plot.R") test_that("CreatePeriodMarkers", { CreatePeriodMarkers <- CausalImpact:::CreatePeriodMarkers times <- 1:50 pre.period <- c(1L, 30L) post.period <- c(31L, 50L) markers <- CreatePeriodMarkers(pre.period, post.period, times) expect_equal(markers, 30) times <- as.numeric(1:50) pre.period <- c(0.5, 30.2) post.period <- c(30.7, 50.5) markers <- CreatePeriodMarkers(pre.period, post.period, times) expect_equal(markers, 30) times <- 1:50 pre.period <- c(11L, 20L) post.period <- c(31L, 40L) markers <- CreatePeriodMarkers(pre.period, post.period, times) expect_equal(markers, c(11, 20, 31, 40)) times <- seq.Date(as.Date("2014-01-01"), by = 1, length.out = 50) pre.period <- as.Date(c("2014-01-01", "2014-01-30")) post.period <- as.Date(c("2014-01-31", "2014-02-19")) markers <- CreatePeriodMarkers(pre.period, post.period, times) expect_equal(markers, as.numeric(as.Date("2014-01-30"))) times <- seq.Date(as.Date("2014-01-01"), by = 7, length.out = 50) pre.period <- c(times[1] - 1, times[30] + 1) post.period <- c(times[31] - 2, times[50] + 1) markers <- CreatePeriodMarkers(pre.period, post.period, times) expect_equal(markers, as.numeric(times[30])) times <- seq.POSIXt(strptime("2014-01-01 00:00:00", format = "%Y-%m-%d %H:%M:%S"), by = 3600, length.out = 48) pre.period <- as.POSIXct(strptime(c("2014-01-01 10:00:00", "2014-01-01 20:00:00"), format = "%Y-%m-%d %H:%M:%S")) post.period <- as.POSIXct(strptime(c("2014-01-02 10:00:00", "2014-01-02 20:00:00"), format = "%Y-%m-%d %H:%M:%S")) markers <- CreatePeriodMarkers(pre.period, post.period, times) expect_equal(markers, as.numeric(strptime(c("2014-01-01 10:00:00", "2014-01-01 20:00:00", "2014-01-02 10:00:00", "2014-01-02 20:00:00"), format = "%Y-%m-%d %H:%M:%S"))) }) test_that("CreateImpactPlot", { CreateImpactPlot <- CausalImpact:::CreateImpactPlot expect_error(CreateImpactPlot()) x <- 1 : 20 y <- x + rnorm(20) + c(rep(0, 10), rep(10, 10)) data <- zoo(cbind(y, x)) pre.period <- c(1, 10) post.period <- c(11, 20) model.args <- list(niter = 500) suppressWarnings(impact <- CausalImpact(data, pre.period, post.period, model.args)) q <- CreateImpactPlot(impact) expect_equal(class(q), c("gg", "ggplot")) expect_error(suppressWarnings(plot(q)), NA) data <- zoo(cbind(y, x), seq.Date(as.Date("2014-01-01"), as.Date("2014-01-20"), by = 1)) pre.period <- as.Date(c("2014-01-01", "2014-01-10")) post.period <- as.Date(c("2014-01-11", "2014-01-20")) suppressWarnings(impact <- CausalImpact(data, pre.period, post.period, model.args)) q <- CreateImpactPlot(impact) expect_equal(class(q), c("gg", "ggplot")) expect_error(suppressWarnings(plot(q)), NA) q1 <- CreateImpactPlot(impact) q2 <- plot(impact) expect_equal(q1, q2, check.environment = FALSE) q1 <- plot(impact) q2 <- plot(impact, c("original", "pointwise", "cumulative")) q3 <- plot(impact, c("o", "point", "c")) expect_equal(q1, q2, check.environment = FALSE) q3$plot_env$metrics <- q2$plot_env$metrics expect_equal(q1, q3, check.environment = FALSE) q1 <- plot(impact, c("p", "c")) q2 <- plot(impact, c("c", "p")) expect_true(!isTRUE(all.equal(q1, q2, check.environment = FALSE))) })
plot.gstar <- function(x, testing = NULL, n_predict = NULL, ...) { if(is.null(testing)) { if(is.null(n_predict)){ all_df <- rbind(as.data.frame(x$data), as.data.frame(x$fitted_values)) if(!is.null(x$Date)) { all_df$Date <- as.Date(row.names(all_df)) } else { all_df$Date <- c(1:nrow(x$data), 1:nrow(x$fitted_values)) } all_df$source <- c(rep("data", nrow(x$data)), rep("fitted_values", nrow(x$fitted_values))) all_df <- reshape2::melt(all_df, id.vars = c("Date", "source")) ggplot(all_df, aes_string(x = "Date", y = "value", color = "source")) + geom_line(aes_string(linetype = "source")) + facet_wrap(.~variable) } else { forecast <- predict(x, n_predict) all_df <- rbind(as.data.frame(x$data), as.data.frame(x$fitted_values), as.data.frame(forecast)) if(!is.null(x$Date)) { all_df$Date <- as.Date(row.names(all_df)) } else { all_df$Date <- c(1:nrow(x$data), 1:nrow(x$fitted_values), (nrow(x$fitted_values) + 1):(nrow(x$fitted_values)+nrow(forecast))) } all_df$source <- c(rep("data", nrow(x$data)), rep("fitted_values", nrow(x$fitted_values)), rep("forecast", n_predict)) all_df <- reshape2::melt(all_df, id.vars = c("Date", "source")) ggplot(all_df, aes_string(x = "Date", y = "value", color = "source")) + geom_line(aes_string(linetype = "source")) + facet_wrap(.~variable) } } else { if(ncol(testing) != ncol(x$data)) { stop("Number column testing and training data are not equal.\nPlease insert appropriate testing data!!") } forecast <- predict(x, nrow(testing)) all_df <- rbind(as.data.frame(x$data), as.data.frame(x$fitted_values), as.data.frame(forecast), as.data.frame(testing)) all_df$source <- c(rep("data", nrow(x$data)), rep("fitted_values", nrow(x$fitted_values)), rep("forecast", nrow(forecast)), rep("testing", nrow(testing))) if(!is.null(x$Date)) { all_df$Date <- as.Date(row.names(all_df)) } else { all_df$Date <- c(1:nrow(x$data), 1:nrow(x$fitted_values), (nrow(x$fitted_values) + 1):(nrow(x$fitted_values)+nrow(forecast)), (nrow(x$fitted_values) + 1):(nrow(x$fitted_values)+nrow(testing))) } all_df <- reshape2::melt(all_df, id.vars = c("Date", "source")) ggplot(all_df, aes_string(x = "Date", y = "value", color = "source")) + geom_line(aes_string(linetype = "source")) + facet_wrap(.~variable) } }
prep.gsda <- function(data.mtx, clin.data, vset.data=NULL) { clin.clms=colnames(clin.data) if (!any(is.element(clin.clms,"ID"))) stop("clin.data must be a data.frame with a column named ID with column names of data.mtx.") id.mtx=colnames(data.mtx) id.grp=clin.data$ID id.mtch=match.order.ids(id.mtx,id.grp) data.mtx=data.mtx[,id.mtch$ind1] clin.data=clin.data[id.mtch$ind2,] id.mtx=colnames(data.mtx) id.grp=clin.data$ID if (any(id.mtx!=id.grp)) stop("Error in merging clin.data and data.mtx.") n=nrow(clin.data) vset.index=NULL if (!is.null(vset.data)) { vset.data0=vset.data ord.dset=order.index.dset(vset.data,"vset") vset.data=ord.dset$dset vset.index=ord.dset$indx nset=nrow(vset.index) ord0=order(vset.data0$vset,vset.data0$vID) ord1=order(vset.data$vset,vset.data$vID) if (any(vset.data0$vID[ord0]!=vset.data$vID[ord1])|| any(vset.data0$vset[ord0]!=vset.data$vset[ord1])) { stop("Error in indexing vset.data.") } for (i in 1:nset) { indx=vset.index[i,1]:vset.index[i,2] uniq.vset=unique(vset.data$vset[indx]) if (length(uniq.vset)!=1) stop("Error in index vset.data") } } res=list(omic.data=data.mtx, clin.data=clin.data, vset.data=vset.data, vset.index=vset.index) return(res) }
"print.fitted.symcoca" <- function(x, digits = max(3, getOption("digits") - 3), ...) { if (!is.null(x[["Y"]])) { cat("\nFitted values for:", x$nam.dat["namY"], "\n") print(zapsmall(x[["Y"]]), digits = digits, ..., print.gap = 2) } if (!is.null(x[["X"]])) { cat("\nFitted values for:", x$nam.dat["namX"], "\n") print(zapsmall(x[["X"]]), digits = digits, ..., print.gap = 2) } invisible(x) }
test_that("ggtitle is translated correctly", { ggpenguin <- ggplot(palmerpenguins::penguins) + geom_point(aes(bill_length_mm, bill_depth_mm)) + ggtitle("My amazing plot!") info <- expect_doppelganger_built(ggpenguin, "labels-ggtitle") expect_identical(info$layout$title$text, "My amazing plot!") }) test_that("ylab is translated correctly", { ggpenguin <- ggplot(palmerpenguins::penguins) + geom_point(aes(bill_length_mm, bill_depth_mm)) + ylab("bill depth") info <- expect_doppelganger_built(ggpenguin, "labels-ylab") labs <- c(info$layout$xaxis$title$text, info$layout$yaxis$title$text) expect_identical(labs, c("bill_length_mm", "bill depth")) }) test_that("scale_x_continuous(name) is translated correctly", { ggpenguin <- ggplot(palmerpenguins::penguins) + geom_point(aes(bill_length_mm, bill_depth_mm)) + scale_x_continuous("bill length") info <- expect_doppelganger_built(ggpenguin, "labels-scale_x_continuous_name") labs <- c(info$layout$xaxis$title$text, info$layout$yaxis$title$text) expect_identical(labs, c("bill length", "bill_depth_mm")) }) test_that("angled ticks are translated correctly", { ggpenguin <- ggplot(palmerpenguins::penguins) + geom_point(aes(bill_length_mm, bill_depth_mm)) + theme(axis.text.x = element_text(angle = 45)) info <- expect_doppelganger_built(ggpenguin, "labels-angles") expect_identical(info$layout$xaxis$tickangle, -45) }) test_that("xaxis/yaxis automargin defaults to TRUE", { p <- ggplot(palmerpenguins::penguins, aes(species)) + geom_bar() + coord_flip() l <- plotly_build(p)$x expect_true(l$layout$xaxis$automargin) expect_true(l$layout$yaxis$automargin) }) test_that("factor labels work", { p <- ggplot(diamonds, aes(cut)) + geom_bar() + scale_x_discrete("Cut", labels=factor(letters[1:5])) b <- expect_doppelganger_built(p, "factor-labels") }) test_that("empty labels work", { p <- ggplot(palmerpenguins::penguins, aes(bill_length_mm, bill_depth_mm, color = species)) + geom_point() + labs(x = element_blank(), y = element_blank()) b <- expect_doppelganger_built(p, "labs-element-blank") })
imcid.hinge.smooth <- function(x, y, z, w, n, parm, lambda, delta) { beta0 <- parm[1] beta <- matrix(parm[-1]) u <- y * (x - beta0 - z %*% beta) val1 <- w * 2 * (1 - 1 / delta * u) ^ 2 * ifelse(u < delta & u >= delta / 2, 1, 0) val2 <- w * (1.5 - 2 / delta * u) * ifelse(u < delta / 2, 1, 0) val <- n * lambda / 2 * sum(beta ^ 2) + sum(val1 + val2) return(val) } imcid.ramp.smooth <- function(x, y, z, w, n, parm, lambda, delta, t) { beta0 <- parm[1] beta <- matrix(parm[-1]) u <- y * (x - beta0 - z %*% beta) val1 <- w * 2 * (1 - 1 / delta * u) ^ 2 * ifelse(u < delta & u >= delta / 2, 1, 0) val2 <- w * (1.5 - 2 / delta * u) * ifelse(u < delta / 2, 1, 0) val3 <- w * u * t val <- n * lambda / 2 * sum(beta ^ 2) + sum(val1 + val2) + n * sum(val3) return(val) } h.ifun <- function(z_tilde, ind1, ind2, w) { h_fun <- drop(4 * (ind1 - ind2)) * w * (z_tilde %*% t(z_tilde)) return(h_fun) } g.ifun <- function(z_tilde, val, ind1, ind2, w) { g_fun <- drop(4 * ((2 - 2 * val) ^ 2 * ind1 + (2 * val) ^ 2 * ind2)) * w ^ 2 * (z_tilde %*% t(z_tilde)) return(g_fun) }
winver_ver <- function(v = NULL) { if (is.null(v)) v <- system("cmd /c ver", intern = TRUE) v2 <- grep("\\[.*\\s.*\\]", v, value = TRUE)[1] v3 <- sub("^.*\\[[^ ]+\\s+", "", v2) v4 <- sub("\\]$", "", v3) if (is.na(v4)) stop("Failed to parse windows version") v4 } winver_wmic <- function(v = NULL) { cmd <- "wmic os get Version /value" if (is.null(v)) v <- system(cmd, intern = TRUE) v2 <- grep("=", v, value = TRUE) v3 <- strsplit(v2, "=", fixed = TRUE)[[1]][2] v4 <- sub("\\s*$", "", sub("^\\s*", "", v3)) if (is.na(v4)) stop("Failed to parse windows version") v4 } winver <- function() { v <- if (Sys.which("wmic") != "") { tryCatch(winver_wmic(), error = function(e) NULL) } if (is.null(v)) winver_ver() else v } if (is.null(sys.calls())) cat(winver())
`aa0.a1a2.b` <- function (a,a0, tol=.Machine$double.eps^.5) ifelse(!(le(0,a) && le(a,a0) && le(a0,1)), NA, ifelse(eq(a,0)||eq(a,1)||eq(a,a0), a, uniroot(function(x) a0a1a2.a.b(a0,x,x) - a, lower=0, upper=a0, tol=tol)$root))
sprinkle_bg_pattern <- function(x, rows = NULL, cols = NULL, bg_pattern = c("transparent", " bg_pattern_by = c("rows", "cols"), ..., part = c("body", "head", "foot", "interoot", "table")) { UseMethod("sprinkle_bg_pattern") } sprinkle_bg_pattern.default <- function(x, rows = NULL, cols = NULL, bg_pattern = c("transparent", " bg_pattern_by = c("rows", "cols"), ..., part = c("body", "head", "foot", "interfoot", "table")) { coll <- checkmate::makeAssertCollection() checkmate::assert_class(x = x, classes = "dust", add = coll) bg_pattern_by <- sprinkle_bg_pattern_index_assert(bg_pattern = bg_pattern, bg_pattern_by = bg_pattern_by, coll = coll) indices <- index_to_sprinkle(x = x, rows = rows, cols = cols, fixed = FALSE, part = part, recycle = "none", coll = coll) checkmate::reportAssertions(coll) part <- part[1] sprinkle_bg_pattern_index(x = x, indices = indices, bg_pattern = bg_pattern, bg_pattern_by = bg_pattern_by, part = part) } sprinkle_bg_pattern.dust_list <- function(x, rows = NULL, cols = NULL, bg_pattern = c("transparent", " bg_pattern_by = c("rows", "cols"), ..., part = c("body", "head", "foot", "interfoot", "table")) { structure( lapply(X = x, FUN = sprinkle_na_string.default, rows = rows, cols = cols, bg_pattern = bg_pattern, bg_pattern_by = bg_pattern_by, part = part, fixed = FALSE, recycle = "none", ...), class = "dust_list" ) } sprinkle_bg_pattern_index_assert <- function(bg_pattern = c("transparent", " bg_pattern_by = c("rows", "cols"), coll) { checkmate::assert_character(x = bg_pattern, add = coll, .var.name = "bg_pattern") if (!all(is_valid_color(bg_pattern))) { coll$push(sprintf("The following elements in `bg_pattern` are not valid colors: %s", paste0(bg_pattern[!is_valid_color(bg_pattern)], collapse = ", "))) } bg_pattern_by <- checkmate::matchArg(x = bg_pattern_by, choices = c("rows", "cols"), add = coll, .var.name = "bg_pattern_by") bg_pattern_by } sprinkle_bg_pattern_index <- function(x, indices, bg_pattern = c("transparent", " bg_pattern_by = c("rows"), part) { if (bg_pattern_by == "rows") { pattern <- data.frame(row = sort(unique(x[[part]][["row"]][indices]))) pattern[["bg"]] <- rep(bg_pattern, length.out = nrow(pattern)) pattern <- dplyr::left_join(pattern, dplyr::select(x[[part]][indices, ], row, col), by = c("row" = "row")) pattern <- dplyr::arrange(pattern, col, row) x[[part]][["bg"]][indices] <- pattern[["bg"]] } else { pattern <- data.frame(col = sort(unique(x[[part]][["col"]][indices]))) pattern[["bg"]] <- rep(bg_pattern, length.out = nrow(pattern)) pattern <- dplyr::left_join(pattern, dplyr::select(x[[part]][indices, ], row, col), by = c("col" = "col")) pattern <- dplyr::arrange(pattern, col, row) x[[part]][["bg"]][indices] <- pattern[["bg"]] } x }
ladderShow <- function(tree, mainCol="black", ladderEdgeCol="red", ladderNodeCol="red", ...) { tree <- phyloCheck(tree) edgeList <- tree$edge nEdges <- nrow(tree$edge) col <- rep(mainCol,nEdges) ladderSizes <- ladderSizes(tree) ladderEdges <- ladderSizes$ladderEdges ladderNodes <- (1:(2*length(tree$tip.label)-1))[ladderSizes$ladderNodes] for (i in ladderEdges) { col[i] <- ladderEdgeCol } plot.phylo(tree,edge.color=col, ...) if(length(ladderNodes)!=0) nodelabels(node=ladderNodes, bg=ladderNodeCol) }
pkg <- "aster" library(pkg, character.only = TRUE) set.seed(42) data(echinacea) vars <- c("ld02", "ld03", "ld04", "fl02", "fl03", "fl04", "hdct02", "hdct03", "hdct04") redata <- reshape(echinacea, varying = list(vars), direction = "long", timevar = "varb", times = as.factor(vars), v.names = "resp") redata <- data.frame(redata, root = 1) pred <- c(0, 1, 2, 1, 2, 3, 4, 5, 6) fam <- c(1, 1, 1, 1, 1, 1, 3, 3, 3) hdct <- grep("hdct", as.character(redata$varb)) hdct <- is.element(seq(along = redata$varb), hdct) redata <- data.frame(redata, hdct = as.integer(hdct)) aout.foo <- aster(resp ~ varb + nsloc + ewloc + pop : hdct, pred, fam, varb, id, root, data = redata, type = "conditional") beta <- aout.foo$coefficients dbeta <- rnorm(length(beta)) pout <- predict(aout.foo, parm.type = "canonical", model.type = "conditional", se.fit = TRUE) theta <- pout$fit dtheta <- as.vector(pout$gradient %*% dbeta) pout <- predict(aout.foo, parm.type = "canonical", model.type = "unconditional", se.fit = TRUE) phi <- pout$fit dphi <- as.vector(pout$gradient %*% dbeta) pout <- predict(aout.foo, parm.type = "mean.value", model.type = "unconditional", se.fit = TRUE) mu <- pout$fit dmu <- as.vector(pout$gradient %*% dbeta) phony <- matrix(1, nrow = nrow(aout.foo$x), ncol = ncol(aout.foo$x)) pout <- predict.aster(aout.foo, x = phony, root = aout.foo$root, modmat = aout.foo$modmat, parm.type = "mean.value", model.type = "conditional", se.fit = TRUE) xi <- pout$fit dxi <- as.vector(pout$gradient %*% dbeta) offset <- as.vector(aout.foo$origin) modmat <- matrix(aout.foo$modmat, ncol = length(beta)) detach(pos = match(paste("package", pkg, sep=":"), search())) rm(list = setdiff(ls(), c("beta", "theta", "phi", "xi", "mu", "tau", "offset", "modmat", "dbeta", "dtheta", "dphi", "dxi", "dmu", "dtau"))) library(aster2) data(echinacea) myphi <- transformSaturated(theta, echinacea, from = "theta", to = "phi") all.equal(phi, myphi) mytheta <- transformSaturated(phi, echinacea, from = "phi", to = "theta") all.equal(theta, mytheta) myxi <- transformSaturated(theta, echinacea, from = "theta", to = "xi") all.equal(xi, myxi) mymu <- transformSaturated(xi, echinacea, from = "xi", to = "mu") all.equal(mu, mymu) phi.foo <- transformConditional(beta, modmat, echinacea, from = "beta", to = "phi", offset = offset) all.equal(phi, phi.foo) theta.foo <- transformConditional(beta, modmat, echinacea, from = "beta", to = "theta", offset = offset) all.equal(theta, theta.foo) xi.foo <- transformConditional(beta, modmat, echinacea, from = "beta", to = "xi", offset = offset) all.equal(xi, xi.foo) mu.foo <- transformConditional(beta, modmat, echinacea, from = "beta", to = "mu", offset = offset) all.equal(mu, mu.foo) dphi.foo <- transformConditional(beta, modmat, echinacea, from = "beta", to = "phi", offset = offset, differential = dbeta) all.equal(dphi, dphi.foo) dtheta.foo <- transformConditional(beta, modmat, echinacea, from = "beta", to = "theta", offset = offset, differential = dbeta) all.equal(dtheta, dtheta.foo) dxi.foo <- transformConditional(beta, modmat, echinacea, from = "beta", to = "xi", offset = offset, differential = dbeta) all.equal(dxi, dxi.foo) dmu.foo <- transformConditional(beta, modmat, echinacea, from = "beta", to = "mu", offset = offset, differential = dbeta) all.equal(dmu, dmu.foo)
create_PDF <- function(user = FALSE, Labels = NULL, name ="LabelsOut", type = "matrix", ErrCorr = "H", Fsz = 12, ...) { custom_create_PDF(user, Labels, name, type, ErrCorr, Fsz, ...) }
context("Trim whitespace") test_that("trim_ws is default and it works", { skip_if(getRversion() < 3.2) xls <- read_excel(test_sheet("whitespace-xls.xls"), col_names = FALSE) xlsx <- read_excel(test_sheet("whitespace-xlsx.xlsx"), col_names = FALSE) expect_identical(xls[[1]], trimws(xls[[1]])) expect_identical(xlsx[[1]], trimws(xlsx[[1]])) expect_identical(xls[[1]], xlsx[[1]]) xls <- read_excel(test_sheet("whitespace-xls.xls")) xlsx <- read_excel(test_sheet("whitespace-xlsx.xlsx")) expect_identical(names(xls), trimws(names(xls))) expect_identical(names(xlsx), trimws(names(xlsx))) expect_identical(names(xls), names(xlsx)) }) test_that("trim_ws = FALSE preserves whitespace", { skip_if(getRversion() < 3.2) xls <- read_excel( test_sheet("whitespace-xls.xls"), col_names = FALSE, trim_ws = FALSE ) xlsx <- read_excel( test_sheet("whitespace-xlsx.xlsx"), col_names = FALSE, trim_ws = FALSE ) expect_false(identical(xls[[1]], trimws(xls[[1]]))) expect_false(identical(xlsx[[1]], trimws(xlsx[[1]]))) ws_only <- grepl("^\\s*$", xls[[1]]) expect_identical(xls[[1]][!ws_only], xlsx[[1]][!ws_only]) xls <- read_excel(test_sheet("whitespace-xls.xls"), trim_ws = FALSE) xlsx <- read_excel(test_sheet("whitespace-xlsx.xlsx"), trim_ws = FALSE) expect_false(identical(names(xls), trimws(names(xls)))) expect_false(identical(names(xlsx), trimws(names(xlsx)))) expect_identical(names(xls), names(xlsx)) }) test_that("whitespace-flanked na strings match when trim_ws = TRUE", { xls <- read_excel( test_sheet("whitespace-xls.xls"), sheet = "logical_and_NA", na = ":-)" ) xlsx <- read_excel( test_sheet("whitespace-xlsx.xlsx"), sheet = "logical_and_NA", na = ":-)" ) expect_is(xls$numeric, "numeric") expect_is(xlsx$numeric, "numeric") expect_true(is.na(xls[[2, 1]])) expect_true(is.na(xlsx[[2, 1]])) }) test_that("whitespace-flanked na strings do not match when trim_ws = FALSE", { xls <- read_excel( test_sheet("whitespace-xls.xls"), sheet = "logical_and_NA", na = ":-)", trim_ws = FALSE ) xlsx <- read_excel( test_sheet("whitespace-xlsx.xlsx"), sheet = "logical_and_NA", na = ":-)", trim_ws = FALSE ) expect_is(xls$numeric, "character") expect_is(xlsx$numeric, "character") expect_identical(xls[[2, 1]], " :-) ") expect_identical(xlsx[[2, 1]], " :-) ") })
context("Factorial Design") test_that("Factorial", { my_population <- declare_model(N = 2000, noise = rnorm(N)) my_potential_outcomes <- declare_potential_outcomes( Y_Z_T1 = noise, Y_Z_T2 = noise + 0.2, Y_Z_T3 = noise + 0.2, Y_Z_T4 = noise + 0.6 ) my_assignment <- declare_assignment(Z = complete_ra(N, num_arms = 4)) my_inquiry <- declare_inquiry(interaction = mean(Y_Z_T4 - Y_Z_T3) - mean(Y_Z_T2 - Y_Z_T1)) my_estimator <- declare_estimator(Y ~ Z1 + Z2 + Z1 * Z2, model = lm_robust, term = "Z1:Z2" ) my_measurement <- declare_measurement(Y = reveal_outcomes(Y ~ Z)) my_design <- my_population + my_potential_outcomes + my_inquiry + my_assignment + declare_step(dplyr::mutate, Z1 = as.numeric(Z %in% c("T2", "T4")), Z2 = as.numeric(Z %in% c("T3", "T4")) ) + my_measurement + my_estimator expect_equal(my_design %>% draw_data() %>% nrow(), 2000) expect_equal(my_design %>% run_design() %>% names(), c("inquiry", "estimand", "estimator", "term", "estimate", "std.error", "statistic", "p.value", "conf.low", "conf.high", "df", "outcome")) diagnosis <- diagnose_design(my_design, sims = 2, bootstrap_sims = FALSE) expect_equal(diagnosis %>% get_simulations %>% dim, c(2, 14)) expect_equal(diagnosis %>% get_diagnosands %>% dim, c(1, 12)) })
setMethod("summary", signature(object = "LcpFinder"), function(object) { lcp_sum <- summarize_lcps(object) ext <- object@ptr$getSearchLimits() sp <- object@ptr$getStartPoint() cat("class : LcpFinder\n", "start point : (", sp[1], ", ", sp[2], ")\n", "search limits : ", ext[1], ", ", ext[2], ", ", ext[3], ", ", ext[4], " (xmin, xmax, ymin, ymax)\n", " } ) setMethod("show", signature(object = "LcpFinder"), function(object) { summary(object) } )
.ident <- function(...){ args <- c(...) if( length( args ) > 2L ){ out <- c( identical( args[1] , args[2] ) , .ident(args[-1])) }else{ out <- identical( args[1] , args[2] ) } return( all( out ) ) } .cp_quantile = function(x, num=10000, cat_levels=8){ nobs = length(x) nuniq = length(unique(x)) if(nuniq==1) { ret = x[1] warning("A supplied covariate contains a single distinct value.") } else if(nuniq < cat_levels) { xx = sort(unique(x)) ret = xx[-length(xx)] + diff(xx)/2 } else { q = approxfun(sort(x),quantile(x,p = 0:(nobs-1)/nobs)) ind = seq(min(x),max(x),length.out=num) ret = q(ind) } return(ret) } bcf <- function(y, z, x_control, x_moderate=x_control, pihat, nburn, nsim, nthin = 1, update_interval = 100, ntree_control = 200, sd_control = 2*sd(y), base_control = 0.95, power_control = 2, ntree_moderate = 50, sd_moderate = sd(y), base_moderate = 0.25, power_moderate = 3, nu = 3, lambda = NULL, sigq = .9, sighat = NULL, include_pi = "control", use_muscale=TRUE, use_tauscale=TRUE ) { pihat = as.matrix(pihat) if( !.ident(length(y), length(z), nrow(x_control), nrow(x_moderate), nrow(pihat) ) ) { stop("Data size mismatch. The following should all be equal: length(y): ", length(y), "\n", "length(z): ", length(z), "\n", "nrow(x_control): ", nrow(x_control), "\n", "nrow(x_moderate): ", nrow(x_moderate), "\n", "nrow(pihat): ", nrow(pihat),"\n" ) } if(any(is.na(y))) stop("Missing values in y") if(any(is.na(z))) stop("Missing values in z") if(any(is.na(x_control))) stop("Missing values in x_control") if(any(is.na(x_moderate))) stop("Missing values in x_moderate") if(any(is.na(pihat))) stop("Missing values in pihat") if(any(!is.finite(y))) stop("Non-numeric values in y") if(any(!is.finite(z))) stop("Non-numeric values in z") if(any(!is.finite(x_control))) stop("Non-numeric values in x_control") if(any(!is.finite(x_moderate))) stop("Non-numeric values in x_moderate") if(any(!is.finite(pihat))) stop("Non-numeric values in pihat") if(!all(sort(unique(z)) == c(0,1))) stop("z must be a vector of 0's and 1's, with at least one of each") if(length(unique(y))<5) warning("y appears to be discrete") if(nburn<0) stop("nburn must be positive") if(nsim<0) stop("nsim must be positive") if(nthin<0) stop("nthin must be positive") if(nthin>nsim+1) stop("nthin must be < nsim") if(nburn<100) warning("A low (<100) value for nburn was supplied") x_c = matrix(x_control, ncol=ncol(x_control)) x_m = matrix(x_moderate, ncol=ncol(x_moderate)) if(include_pi=="both" | include_pi=="control") { x_c = cbind(x_control, pihat) } if(include_pi=="both" | include_pi=="moderate") { x_m = cbind(x_moderate, pihat) } cutpoint_list_c = lapply(1:ncol(x_c), function(i) .cp_quantile(x_c[,i])) cutpoint_list_m = lapply(1:ncol(x_m), function(i) .cp_quantile(x_m[,i])) yscale = scale(y) sdy = sd(y) muy = mean(y) if(is.null(lambda)) { if(is.null(sighat)) { lmf = lm(yscale~z+as.matrix(x_c)) sighat = summary(lmf)$sigma } qchi = qchisq(1.0-sigq,nu) lambda = (sighat*sighat*qchi)/nu } dir = tempdir() perm = order(z, decreasing=TRUE) fitbcf = bcfoverparRcppClean(yscale[perm], z[perm], t(x_c[perm,]), t(x_m[perm,,drop=FALSE]), t(x_m[1,,drop=FALSE]), cutpoint_list_c, cutpoint_list_m, random_des = matrix(1), random_var = matrix(1), random_var_ix = matrix(1), random_var_df = 3, nburn, nsim, nthin, ntree_moderate, ntree_control, lambda, nu, con_sd = ifelse(abs(2*sdy - sd_control)<1e-6, 2, sd_control/sdy), mod_sd = ifelse(abs(sdy - sd_moderate)<1e-6, 1, sd_moderate/sdy)/ifelse(use_tauscale,0.674,1), base_control, power_control, base_moderate, power_moderate, tempdir(), status_interval = update_interval, use_mscale = use_muscale, use_bscale = use_tauscale, b_half_normal = TRUE) m_post = muy + sdy*fitbcf$m_post[,order(perm)] tau_post = sdy*fitbcf$b_post[,order(perm)] list(sigma = sdy*fitbcf$sigma, yhat = muy + sdy*fitbcf$yhat_post[,order(perm)], tau = tau_post, mu_scale = fitbcf$msd*sdy, tau_scale = fitbcf$bsd*sdy, perm = perm ) }
"freq.curve.all" <- function(lmom,aslog10=FALSE,asprob=TRUE, no2para=FALSE,no3para=FALSE,no4para=FALSE,no5para=FALSE, step=FALSE,show=FALSE, xmin=NULL,xmax=NULL,xlim=NULL, ymin=NULL,ymax=NULL,ylim=NULL, aep4=FALSE,exp=TRUE,gam=TRUE,gev=TRUE,gld=FALSE, glo=TRUE,gno=TRUE,gpa=TRUE,gum=TRUE,kap=TRUE, nor=TRUE,pe3=TRUE,wak=TRUE,wei=TRUE,...) { if(! are.lmom.valid(lmom)) { warning("L-moments are invalid") return() } if(no2para) { exp <- FALSE gam <- FALSE gum <- FALSE nor <- FALSE } if(no3para) { gev <- FALSE glo <- FALSE gno <- FALSE gpa <- FALSE pe3 <- FALSE wei <- FALSE } if(no4para) { aep4 <- FALSE gld <- FALSE kap <- FALSE } if(no5para) { wak <- FALSE } F <- nonexceeds() n <- length(F) AEP4 <- EXP <- GAM <- GEV <- GLD <- GLO <- GNO <- vector(mode="numeric",length=n) GPA <- GUM <- KAP <- NOR <- PE3 <- WAK <- WEI <- vector(mode="numeric",length=n) if(aep4 == TRUE) { if(show == TRUE) cat("4-p Asymmetric Exponential Power distribution (takes awhile)--") P <- paraep4(lmom,...) if(show == TRUE) cat("parameters--") if(P$type == "kap") { message(" For AEP4 logic and AEP4 solution does not exist, no quantiles will be computed") } else { AEP4 <- quaaep4(F,P) if(aslog10 == TRUE) AEP4 <- log10(AEP4) if(show == TRUE) cat("quantiles\n") } } if(exp == TRUE) { if(show == TRUE) cat("Exponential distribution--") P <- parexp(lmom) if(show == TRUE) cat("parameters--") EXP <- quaexp(F,P) if(aslog10 == TRUE) EXP <- log10(EXP) if(show == TRUE) cat("quantiles\n") } if(gam == TRUE) { if(show == TRUE) cat("Gamma distribution--") P <- pargam(lmom) if(show == TRUE) cat("parameters--") GAM <- quagam(F,P) if(aslog10 == TRUE) GAM <- log10(GAM) if(show == TRUE) cat("quantiles\n") } if(gev == TRUE) { if(show == TRUE) cat("Generalized Extreme Value distribution--") P <- pargev(lmom) if(show == TRUE) cat("parameters--") GEV <- quagev(F,P) if(aslog10 == TRUE) GEV <- log10(GEV) if(show == TRUE) cat("quantiles\n") } if(gld == TRUE) { if(show == TRUE) cat("Generalized Lambda distribution (takes awhile)--") P <- pargld(lmom,...) if(show == TRUE) cat("parameters--") GLD <- quagld(F,P) if(aslog10 == TRUE) GLD <- log10(GLD) if(show == TRUE) cat("quantiles\n") } if(glo == TRUE) { if(show == TRUE) cat("Generalized Logistic distribution--") P <- parglo(lmom) if(show == TRUE) cat("parameters--") GLO <- quaglo(F,P) if(aslog10 == TRUE) GLO <- log10(GLO) if(show == TRUE) cat("quantiles\n") } if(gno == TRUE) { if(show == TRUE) cat("Generalized Normal distribution--") P <- pargno(lmom) if(show == TRUE) cat("parameters--") GNO <- quagno(F,P) if(aslog10 == TRUE) GNO <- log10(GNO) if(show == TRUE) cat("quantiles\n") } if(gpa == TRUE) { if(show == TRUE) cat("Generalized Pareto distribution--") P <- pargpa(lmom) if(show == TRUE) cat("parameters--") GPA <- quagpa(F,P) if(aslog10 == TRUE) GPA <- log10(GPA) if(show == TRUE) cat("quantiles\n") } if(gum == TRUE) { if(show == TRUE) cat("Generalized Gumbel distribution--") P <- pargum(lmom) if(show == TRUE) cat("parameters--") GUM <- quagum(F,P) if(aslog10 == TRUE) GUM <- log10(GUM) if(show == TRUE) cat("quantiles\n") } if(kap == TRUE) { if(show == TRUE) cat("Kappa distribution--") P <- parkap(lmom) if(show == TRUE) cat("parameters--") KAP <- quakap(F,P) if(aslog10 == TRUE) KAP <- log10(KAP) if(show == TRUE) cat("quantiles\n") } if(nor == TRUE) { if(show == TRUE) cat("Normal distribution--") P <- parnor(lmom) if(show == TRUE) cat("parameters--") NOR <- quanor(F,P) if(aslog10 == TRUE) NOR <- log10(NOR) if(show == TRUE) cat("quantiles\n") } if(pe3 == TRUE) { if(show == TRUE) cat("Pearson Type III distribution--") P <- parpe3(lmom) if(show == TRUE) cat("parameters--") PE3 <- quape3(F,P) if(aslog10 == TRUE) PE3 <- log10(PE3) if(show == TRUE) cat("quantiles\n") } if(wak == TRUE) { if(show == TRUE) cat("Wakeby distribution--") P <- parwak(lmom) if(show == TRUE) cat("parameters--") if(P$ifail == 2) { message(" For WAK logic a WAK solution does not exist, no quantiles will be computed") } else { WAK <- quawak(F,P) if(aslog10 == TRUE) WAK <- log10(WAK) if(show == TRUE) cat("quantiles\n") } } if(wei == TRUE) { if(show == TRUE) cat("Weibull distribution--") P <- parwei(lmom) if(show == TRUE) cat("parameters--") WEI <- quawei(F,P) if(aslog10 == TRUE) WEI <- log10(WEI) if(show == TRUE) cat("quantiles\n") } if(all(AEP4 == 0)) AEP4 <- rep(NA, n) if(all(EXP == 0)) EXP <- rep(NA, n) if(all(GAM == 0)) GAM <- rep(NA, n) if(all(GEV == 0)) GEV <- rep(NA, n) if(all(GLD == 0)) GLD <- rep(NA, n) if(all(GLO == 0)) GLO <- rep(NA, n) if(all(GNO == 0)) GNO <- rep(NA, n) if(all(GPA == 0)) GPA <- rep(NA, n) if(all(GUM == 0)) GUM <- rep(NA, n) if(all(KAP == 0)) KAP <- rep(NA, n) if(all(NOR == 0)) NOR <- rep(NA, n) if(all(PE3 == 0)) PE3 <- rep(NA, n) if(all(WAK == 0)) WAK <- rep(NA, n) if(all(WEI == 0)) WEI <- rep(NA, n) Q <- data.frame(nonexceeds = F, aep4 = AEP4, exp = EXP, gam = GAM, gev = GEV, glo = GLO, gld = GLD, gno = GNO, gpa = GPA, gum = GUM, kap = KAP, nor = NOR, pe3 = PE3, wak = WAK, wei = WEI) if(show == TRUE) { xlab <- "NONEXCEEDANCE PROBABILITY" if(asprob == TRUE) { F <- qnorm(F) xlab <- "STANDARD NORMAL VARIATE" } limx <- range(F,finite=TRUE) if(length(xmin) == 1) limx[1] <- xmin if(length(xmax) == 1) limx[2] <- xmin if(length(xlim) == 2) limx <- xlim limy <- range(AEP4,EXP,GAM,GEV,GLO,GLD,GNO,GPA,GUM,KAP,NOR,PE3,WAK,WEI,finite=TRUE) if(length(ymin) == 1) limy[1] <- ymin if(length(ymax) == 1) limy[2] <- ymin if(length(ylim) == 2) limy <- ylim plot(F,F,type='n',xlim=c(limx[1],limx[2]), ylim=c(limy[1],limy[2]), xlab=xlab, ylab="QUANTILES") lines(F,Q$aep4,col=6,lty=2, lwd=2) lines(F,Q$exp, col=2) lines(F,Q$gam, col=2) lines(F,Q$gev, col=3) lines(F,Q$glo, col=3) lines(F,Q$gld, col=4, lty=2, lwd=2) lines(F,Q$gno, col=3) lines(F,Q$gpa, col=3) lines(F,Q$gum, col=2) lines(F,Q$kap, col=4, lwd=2) lines(F,Q$nor, col=1) lines(F,Q$pe3, col=3) lines(F,Q$wak, col=6) lines(F,Q$wei, col=3, lty=2) } return(Q) }
"pringles_hardness" data(pringles_hardness, envir=environment())
context("risk difference analysis") load(system.file("extdata", "NLA_IN.rda", package = "spsurvey")) popsize <- data.frame( LAKE_ORGN = c("MAN_MADE", "NATURAL"), Total = c(6000, 14000) ) fpc1 <- 20000 fpc2a <- list( Urban = 5000, "Non-Urban" = 15000 ) fpc2b <- list( MAN_MADE = 6000, NATURAL = 14000 ) fpc3 <- c( Ncluster = 200, clusterID_1 = 100, clusterID_2 = 100, clusterID_3 = 100, clusterID_4 = 100 ) fpc4a <- list( Urban = c( Ncluster = 75, clusterID_1 = 50, clusterID_2 = 50, clusterID_3 = 50, clusterID_4 = 50 ), "Non-Urban" = c( Ncluster = 125, clusterID_1 = 50, clusterID_2 = 50, clusterID_3 = 50, clusterID_4 = 50 ) ) fpc4b <- list( NATURAL = c( Ncluster = 130, clusterID_1 = 50, clusterID_2 = 50, clusterID_3 = 50, clusterID_4 = 50 ), MAN_MADE = c( Ncluster = 70, clusterID_1 = 50, clusterID_2 = 50, clusterID_3 = 50, clusterID_4 = 50 ) ) vars_response <- c("BENT_MMI_COND_2017") vars_stressor <- c("PTL_COND", "NTL_COND") subpops <- c("All_Sites", "LAKE_ORGN") DiffRisk_Estimates <- diffrisk_analysis( dframe = NLA_IN, vars_response = vars_response, vars_stressor = vars_stressor, subpops = subpops, siteID = "SITE_ID", weight = "WGT_TP", xcoord = "XCOORD", ycoord = "YCOORD" ) test_that("Risk Difference: Unstratified single-stage analysis", { expect_true(exists("DiffRisk_Estimates")) expect_equal(attributes(DiffRisk_Estimates)$class, "data.frame") expect_equal(nrow(DiffRisk_Estimates), 6) }) DiffRisk_Estimates <- diffrisk_analysis( dframe = NLA_IN, vars_response = vars_response, vars_stressor = vars_stressor, subpops = subpops, siteID = "SITE_ID", weight = "WGT_TP", xcoord = "XCOORD", ycoord = "YCOORD", popsize = popsize ) test_that("Risk Difference: with known population sizes", { expect_true(exists("DiffRisk_Estimates")) expect_equal(attributes(DiffRisk_Estimates)$class, "data.frame") expect_equal(nrow(DiffRisk_Estimates), 6) }) DiffRisk_Estimates <- diffrisk_analysis( dframe = NLA_IN, vars_response = vars_response, vars_stressor = vars_stressor, subpops = subpops, siteID = "SITE_ID", weight = "WGT_TP", xcoord = "XCOORD", ycoord = "YCOORD", fpc = fpc1 ) test_that("Risk Difference: with finite population correction factor", { expect_true(exists("DiffRisk_Estimates")) expect_equal(attributes(DiffRisk_Estimates)$class, "data.frame") expect_equal(nrow(DiffRisk_Estimates), 6) }) DiffRisk_Estimates <- diffrisk_analysis( dframe = NLA_IN, vars_response = vars_response, vars_stressor = vars_stressor, subpops = subpops, siteID = "SITE_ID", weight = "WGT_TP", xcoord = "XCOORD", ycoord = "YCOORD", stratumID = "URBN_NLA17" ) test_that("Risk Difference: Stratified single-stage analysis", { expect_true(exists("DiffRisk_Estimates")) expect_equal(attributes(DiffRisk_Estimates)$class, "data.frame") expect_equal(nrow(DiffRisk_Estimates), 6) }) DiffRisk_Estimates <- diffrisk_analysis( dframe = NLA_IN, vars_response = vars_response, vars_stressor = vars_stressor, subpops = subpops, siteID = "SITE_ID", weight = "WGT_TP", xcoord = "XCOORD", ycoord = "YCOORD", stratumID = "URBN_NLA17", popsize = popsize ) test_that("Risk Difference: with known population sizes", { expect_true(exists("DiffRisk_Estimates")) expect_equal(attributes(DiffRisk_Estimates)$class, "data.frame") expect_equal(nrow(DiffRisk_Estimates), 6) }) DiffRisk_Estimates <- diffrisk_analysis( dframe = NLA_IN, vars_response = vars_response, vars_stressor = vars_stressor, subpops = subpops, siteID = "SITE_ID", weight = "WGT_TP", xcoord = "XCOORD", ycoord = "YCOORD", stratumID = "URBN_NLA17", fpc = fpc2a ) test_that("Risk Difference: with finite population correction factor", { expect_true(exists("DiffRisk_Estimates")) expect_equal(attributes(DiffRisk_Estimates)$class, "data.frame") expect_equal(nrow(DiffRisk_Estimates), 6) }) DiffRisk_Estimates <- diffrisk_analysis( dframe = NLA_IN, vars_response = vars_response, vars_stressor = vars_stressor, subpops = subpops, siteID = "SITE_ID", weight = "WGT_TP", xcoord = "XCOORD", ycoord = "YCOORD", clusterID = "clusterID", weight1 = "weight1", xcoord1 = "xcoord1", ycoord1 = "ycoord1", vartype = "SRS" ) test_that("Risk Difference: Unstratified two-stage analysis", { expect_true(exists("DiffRisk_Estimates")) expect_equal(attributes(DiffRisk_Estimates)$class, "data.frame") expect_equal(nrow(DiffRisk_Estimates), 6) }) DiffRisk_Estimates <- diffrisk_analysis( dframe = NLA_IN, vars_response = vars_response, vars_stressor = vars_stressor, subpops = subpops, siteID = "SITE_ID", weight = "WGT_TP", xcoord = "XCOORD", ycoord = "YCOORD", clusterID = "clusterID", weight1 = "weight1", xcoord1 = "xcoord1", ycoord1 = "ycoord1", popsize = popsize ) test_that("Risk Difference: with known population sizes", { expect_true(exists("DiffRisk_Estimates")) expect_equal(attributes(DiffRisk_Estimates)$class, "data.frame") expect_equal(nrow(DiffRisk_Estimates), 6) }) DiffRisk_Estimates <- diffrisk_analysis( dframe = NLA_IN, vars_response = vars_response, vars_stressor = vars_stressor, subpops = subpops, siteID = "SITE_ID", weight = "WGT_TP", xcoord = "XCOORD", ycoord = "YCOORD", clusterID = "clusterID", weight1 = "weight1", xcoord1 = "xcoord1", ycoord1 = "ycoord1", fpc = fpc3, vartype = "SRS" ) test_that("Risk Difference: with finite population correction factor", { expect_true(exists("DiffRisk_Estimates")) expect_equal(attributes(DiffRisk_Estimates)$class, "data.frame") expect_equal(nrow(DiffRisk_Estimates), 6) }) DiffRisk_Estimates <- diffrisk_analysis( dframe = NLA_IN, vars_response = vars_response, vars_stressor = vars_stressor, subpops = subpops, siteID = "SITE_ID", weight = "WGT_TP", xcoord = "XCOORD", ycoord = "YCOORD", stratumID = "URBN_NLA17", clusterID = "clusterID", weight1 = "weight1", xcoord1 = "xcoord1", ycoord1 = "ycoord1", vartype = "SRS" ) test_that("Risk Difference: Stratified two-stage analysis", { expect_true(exists("DiffRisk_Estimates")) expect_equal(attributes(DiffRisk_Estimates)$class, "data.frame") expect_equal(nrow(DiffRisk_Estimates), 6) }) DiffRisk_Estimates <- diffrisk_analysis( dframe = NLA_IN, vars_response = vars_response, vars_stressor = vars_stressor, subpops = subpops, siteID = "SITE_ID", weight = "WGT_TP", xcoord = "XCOORD", ycoord = "YCOORD", stratumID = "URBN_NLA17", clusterID = "clusterID", weight1 = "weight1", xcoord1 = "xcoord1", ycoord1 = "ycoord1", popsize = popsize, vartype = "SRS" ) test_that("Risk Difference: with known population sizes", { expect_true(exists("DiffRisk_Estimates")) expect_equal(attributes(DiffRisk_Estimates)$class, "data.frame") expect_equal(nrow(DiffRisk_Estimates), 6) }) DiffRisk_Estimates <- diffrisk_analysis( dframe = NLA_IN, vars_response = vars_response, vars_stressor = vars_stressor, subpops = subpops, siteID = "SITE_ID", weight = "WGT_TP", xcoord = "XCOORD", ycoord = "YCOORD", stratumID = "URBN_NLA17", clusterID = "clusterID", weight1 = "weight1", xcoord1 = "xcoord1", ycoord1 = "ycoord1", fpc = fpc4a, vartype = "SRS" ) test_that("Risk Difference: with finite population correction factor", { expect_true(exists("DiffRisk_Estimates")) expect_equal(attributes(DiffRisk_Estimates)$class, "data.frame") expect_equal(nrow(DiffRisk_Estimates), 6) })
context("test read_excel_sheet") test_that("read_excel_sheet works", { result <- c( NA, "Total e1", NA, "78.31", "73.680000000000007", "48.120000000000005", "78.009999999999991", "278.12", "70.699999999999989", "93.899999999999991", "35.010000000000005", "66", "72", "337.61", "39.659999999999997", "13.98", "40.92", "42.98", "100.92", "238.46", "40.72", "45.57", "47.04", "49.76", "43.2", "226.29000000000002", "1080.48" ) file <- system.file("extdata", "excel/set_sheets.xlsx", package = "flattabler") pt <- read_excel_sheet(file, sheetName = "M3") pt <- pt[, 5] expect_equal(pt, result) pt <- read_excel_sheet(file, sheetIndex = 2) pt <- pt[, 5] expect_equal(pt, result) })
InternetProvider <- R6::R6Class( inherit = BaseProvider, 'InternetProvider', public = list( locale = NULL, safe_email_tlds = c('org', 'com', 'net'), free_email_domains = c('gmail.com', 'yahoo.com', 'hotmail.com'), tlds = c( 'com', 'com', 'com', 'com', 'com', 'com', 'biz', 'info', 'net', 'org' ), uri_pages = c( 'index', 'home', 'search', 'main', 'post', 'homepage', 'category', 'register', 'login', 'faq', 'about', 'terms', 'privacy', 'author' ), uri_paths = c( 'app', 'main', 'wp-content', 'search', 'category', 'tag', 'categories', 'tags', 'blog', 'posts', 'list', 'explore' ), uri_extensions = c( '.html', '.html', '.html', '.htm', '.htm', '.php', '.php', '.jsp', '.asp' ), user_name_formats = c( '{{last_names}}.{{first_names}}', '{{first_names}}.{{last_names}}', '{{first_names}} '?{{last_names}}' ), email_formats = c('{{user_name}}@{{domain_name}}', '{{user_name}}@{{free_email_domain}}'), url_formats = c('www.{{domain_name}}/', '{{domain_name}}/'), uri_formats = c( '{{url}}', '{{url}}{{uri_page}}/', '{{url}}{{uri_page}}{{uri_extension}}', '{{url}}{{uri_path}}/{{uri_page}}/', '{{url}}{{uri_path}}/{{uri_page}}{{uri_extension}}' ), image_placeholder_services = c( 'https://placeholdit.imgix.net/~text?txtsize=55&txt={{width}}x{{height}}&w={{width}&h={{height}}', 'https://www.lorempixel.com/{{width}}/{{height}}', 'https://dummyimage.com/{{width}}x{{height}}' ), replacements = list(), allowed_locales = function() private$locales, initialize = function(locale = NULL) { if (!is.null(locale)) { super$check_locale(locale) check_locale_(locale, private$locales) self$locale <- locale } else { self$locale <- 'en_US' } private$parse_eval_safe('free_email_domains') private$parse_eval_safe('safe_email_tlds') private$parse_eval_safe('email_formats') private$parse_eval_safe('user_name_formats') private$parse_eval_safe('tlds') private$parse_eval_safe('replacements') private$parse_eval_safe('safe_email_tlds') }, to_ascii = function(x) { if (length(self$replacements) != 0) { for (i in seq_along(self$replacements)) { x <- gsub(self$replacements[1], self$replacements[2], x) } } check4pkg("stringi") stringi::stri_trans_general(x, "latin-ascii") }, email = function(domain = NULL) { if (!is.null(domain)) { sprintf('%s@%s', self$user_name(), domain) } else { pattern <- super$random_element(self$email_formats) out <- list( user_name = self$user_name(), domain_name = self$domain_name(), free_email_domain = self$free_email_domain() ) whisker::whisker.render(pattern, data = out) } }, safe_email = function() { tolower(sprintf('%s@example.%s', self$user_name(), super$random_element(self$safe_email_tlds) )) }, free_email = function() { tolower(paste0(self$user_name(), '@', self$free_email_domain())) }, company_email = function() { tolower(paste0(self$user_name(), '@', self$domain_name())) }, ascii_email = function() { pattern <- super$random_element(self$email_formats) out <- list( user_name = self$user_name(), domain_name = self$domain_name(), free_email_domain = self$free_email_domain() ) tolower(self$to_ascii(whisker::whisker.render(pattern, data = out))) }, ascii_safe_email = function() { tolower(self$to_ascii( paste0(self$user_name(), '@example.', super$random_element(self$safe_email_tlds)) )) }, ascii_free_email = function() { tolower(self$to_ascii( paste0(self$user_name(), '@', self$free_email_domain()) )) }, ascii_company_email = function() { tolower(self$to_ascii(paste0(self$user_name(), '@', self$domain_name()))) }, user_name = function() { pattern <- super$random_element(self$user_name_formats) loc <- if (private$has_locale(self$locale, PersonProvider$new()$allowed_locales())) { self$locale } else { "en_US" } out <- PersonProvider$new(locale = loc)$render(pattern) self$to_ascii(tolower(super$bothify(out))) }, tld = function() { super$random_element(self$tlds) }, free_email_domain = function() { super$random_element(self$free_email_domains) }, url = function(schemes = NULL) { if (is.null(schemes)) schemes <- c('http', 'https') pattern <- sprintf( '%s://%s', if (!is.null(schemes)) super$random_element(schemes) else "", super$random_element(self$url_formats) ) whisker::whisker.render( template = pattern, data = list(domain_name = self$domain_name())) }, domain_name = function(levels = 1) { if (levels < 1) { stop("levels must be greater than or equal to 1") } else if (levels == 1) { paste0(self$domain_word(), '.', self$tld()) } else { paste0(self$domain_word(), '.', self$domain_name(levels - 1)) } }, domain_word = function() { company <- CompanyProvider$new() xx <- company$company() xxx <- strsplit(xx, split = "\\s|-")[[1]] tolower(self$to_ascii(xxx[2])) }, ipv4 = function() { check4pkg("iptools") iptools::ip_random(1) }, mac_address = function() { mac = replicate(7, super$random_int(0, 255)) paste0(sprintf("%02x", mac), collapse = ":") }, uri_page = function() { super$random_element(self$uri_pages) }, uri_path = function(deep = NULL) { deep <- if (!is.null(deep)) deep else super$random_int(1, 4) paste0( replicate(deep, super$random_element(self$uri_paths)), collapse = "/" ) }, uri_extension = function() { super$random_element(self$uri_extensions) }, uri = function() { pattern <- super$random_element(self$uri_formats) '{{url}}{{uri_path}}/{{uri_page}}{{uri_extension}}' dat <- list( url = self$url(), uri_path = self$uri_path(), uri_page = self$uri_page(), uri_extension = self$uri_extension() ) tolower(self$to_ascii(whisker::whisker.render(pattern, data = dat))) }, slug = function(value = NULL) { if (is.null(value)) value <- paste0(LoremProvider$new()$words(), collapse = "-") return(value) }, image_url = function(width = NULL, height = NULL) { width_ = if (!is.null(width)) width else super$random_int(max = 1024) height_ = if (!is.null(height)) height else super$random_int(max = 1024) placeholder_url = super$random_element(self$image_placeholder_services) whisker::whisker.render(placeholder_url, data = list(width = width_, height = height_)) } ), private = list( has_locale = function(locale, provider) locale %in% provider, parse_eval_safe = function(name) { if (self$locale != "en_US") { tmp <- parse_eval(sprintf("int_%s_", name), self$locale) if (!is.null(tmp)) self[[name]] <- tmp } }, locales = c("en_US", "en_AU", "en_NZ", "de_DE", "bg_BG", "cs_CZ", "fa_IR", "fr_FR", "hr_HR") ) )
PanEstFun <- function(x1, x2) { n1 <- sum(x1) n2 <- sum(x2) D12 <- sum(x1 > 0 & x2 > 0) f11 <- sum(x1 == 1 & x2 == 1) f22 <- sum(x1 == 2 & x2 == 2) f1p <- sum(x1 == 1 & x2 >= 1) fp1 <- sum(x1 >= 1 & x2 == 1) f2p <- sum(x1 == 2 & x2 >= 1) fp2 <- sum(x1 >= 1 & x2 == 2) K1 <- (n1 - 1) / n1 K2 <- (n2 - 1) / n2 if (f2p == 0 || fp2 == 0 || f22 == 0) { est <- D12 + K1 * f1p * (f1p - 1) / 2 / (f2p + 1) + K2 * fp1 * (fp1 - 1) / 2 / (fp2 + 1) + K1 * K2 * f11 * (f11 - 1) / 4 / (f22 + 1) } else { est <- D12 + K1 * f1p^2 / 2 / f2p + K2 * fp1^2 / 2 / fp2 + K1 * K2 * f11^2 / 4 / f22 } return(est) }
"providers"
context('test-sensor_filterDate') data('example_sensor') test_that( 'Filter Date works', expect_equivalent( sensor_filterDate( example_sensor, startdate = 20180815, enddate = 20180816, timezone = 'UTC' )$data$datetime, sensor_filter( example_sensor, .data$datetime >= lubridate::ymd_h(2018081500, tz = 'UTC'), .data$datetime < lubridate::ymd_h(2018081600, tz = 'UTC') )$data$datetime ) )
searchTxnyms <- function (tree, cache=FALSE, parent=NULL, clean=TRUE, infer=TRUE) { tip_labels <- gsub ('_', ' ', tree@tips) nids <- tree@nds nd_labels <- rep(NA, tree@nall) names(nd_labels) <- tree@all taxa_res <- taxaResolve(tip_labels, datasource=4, cache=cache, parent=parent) if(is.null(taxa_res)) { return(NULL) } nd_labels[tree@tips] <- vapply(strsplit(tip_labels, "\\s+"), function(x) x[1], character(1)) nds_kids <- getNdsKids(tree, ids=nids) for(nid in nids) { kids <- gsub("_" , " ", nds_kids[[nid]]) genus_names <- vapply(strsplit(kids, "\\s+"), function(x) x[1], character(1)) if(all(genus_names == genus_names[1])) { nd_labels[nid] <- genus_names[1] } else { lineages <- as.character(taxa_res[taxa_res$search.name %in% kids, "lineage"]) lineages <- strsplit (lineages, "\\|") lineages <- lineages[!is.na (lineages)] if(length (lineages) > 1) { nd_labels[nid] <- .findClade(lineages) } } } if(clean) { nd_labels <- gsub('\\s', '_', nd_labels) nd_labels <- gsub('[^a-zA-Z_0-9]', '', nd_labels) } if(infer & any(is.na(nd_labels))) { if(sum(is.na(nd_labels))/length(nd_labels) > 0.5) { message('Fewer than 50% of nodes identified,', ' not attempting inference of remaning nodes.') } else { for(i in which(is.na(nd_labels))) { prids <- getNdPrids(tree, names(nd_labels)[i]) pssbls <- nd_labels[prids] pssbls <- pssbls[!is.na(pssbls)] if(length(pssbls) > 0) { nd_labels[[i]] <- pssbls[[1]] } } } } nd_labels } taxaResolve <- function (nms, batch=100, datasource=4, genus=TRUE, cache=FALSE, parent=NULL) { .replace <- function (i, slot.name) { element <- data[[i]]$result[[1]][[slot.name]] if (!is.null (element)) { res <- element } else { res <- NA } res } batchResolve <- function (batch.nms) { url <- "http://resolver.globalnames.org/name_resolvers.json?" data_source_ids <- paste0 ("&data_source_ids=", datasource) nms2 <- paste0 ("names=", paste0 (stringr::str_replace_all ( batch.nms, " ", "+"), collapse = "|")) query <- paste (plyr::compact (list (url, nms2, data_source_ids)), collapse = "") data <- .safeFromJSON(query)$data return(data) } avoid <- c ('unidentified') trms <- gsub ('_', ' ', nms) trms <- gsub ('\\W+', ' ', trms) trms <- gsub ('^\\s+|\\s+$', '', trms) trms[trms==''] <- 'invalid' deja_vues <- rep(FALSE, length(trms)) data <- vector("list", length=length(trms)) names(data) <- nms if(cache) { if(!file.exists("gnr_cache")) { dir.create("gnr_cache") } for(i in 1:length(nms)) { fp <- file.path("gnr_cache", paste0(nms[i], ".RData")) if(file.exists(fp)) { load(fp) data[[nms[i]]] <- nd deja_vues[i] <- TRUE } } } if(sum(!deja_vues) > 0) { x <- seq_along (trms[!deja_vues]) btrms <- split (trms[!deja_vues], ceiling (x/batch)) bnms <- split (nms[!deja_vues], ceiling (x/batch)) for (i in 1:length(btrms)) { temp.data <- batchResolve(btrms[[i]]) if (is.null(temp.data)) { return(NULL) } data[bnms[[i]]] <- temp.data } } search.name <- name.string <- canonical.form <- lineage <- lineage.ids <- rank <- taxid <- match.type <- prescore <- score <- rep (NA, length (nms)) for (i in 1:length (data)){ parent_test <- TRUE nd <- data[[i]] if(cache & !deja_vues[i]) { fp <- file.path("gnr_cache", paste0(names(data)[i], ".RData")) save(nd, file=fp) } if (!'results' %in% names (nd)){ search.name[i] <- nms[i] } else if (nd[[1]] %in% avoid) { search.name[i] <- nms[i] } else { search.name[i] <- nms[i] lng <- .replace(i, 'classification_path') if(!is.null(parent)) { parent_test <- grepl(parent, lng) } if(parent_test) { name.string[i] <- .replace(i, 'name_string') canonical.form[i] <- .replace(i, 'canonical_form') lineage[i] <- lng lineage.ids[i] <- .replace(i, 'classification_path_ids') rank[i] <- .replace(i, 'classification_path_ranks') taxid[i] <- .replace(i, 'taxon_id') match.type[i] <- .replace(i, 'match_type') prescore[i] <- .replace(i, 'prescore') score[i] <- nd$results[[1]]$score } } } res <- data.frame (search.name=search.name, name.string=name.string, canonical.form=canonical.form, lineage=lineage, lineage.ids=lineage.ids, rank=rank, taxid=taxid, match.type=match.type, prescore=prescore, score=score, stringsAsFactors=FALSE) failed <- which (is.na (res$name.string)) if (genus & length (failed) > 0) { genus.nms <- sub ('\\s+.*', '', res$search.name[failed]) genus.res <- taxaResolve(genus.nms, batch, datasource, genus=FALSE, parent=parent, cache=cache) res[failed,-1] <- genus.res[ ,-1] } return (res) } .safeFromJSON <- function (url, max_trys=5, power=2) { trys <- 0 waittime <- 2 while (trys < max_trys) { json_obj <- try (RJSONIO::fromJSON(url), silent = TRUE) if(class(json_obj) == 'try-error') { cat('---- Connection failed: trying again in [', waittime, 's]----\n', sep='') trys <- trys + 1 Sys.sleep(waittime) waittime <- waittime*power } else { return (json_obj) } } warning("Failed to connect, server may be down.") list('data' = NULL) } .findClade <- function(lineages) { subj <- lineages[[1]] for(i in 2:length(lineages)) { query <- lineages[[i]] subj <- subj[subj %in% query] } subj[length(subj)] }
rx_begin_capture <- function(.data = NULL) { new_rx(paste0(.data, "(")) } rx_end_capture <- function(.data = NULL) { new_rx(paste0(.data, ")")) }
"apcalcm"
skip_on_cran() skip_on_os(os = "windows") small_table_sqlite <- small_table_sqlite() small_table_duckdb <- db_tbl(table = small_table, dbname = ":memory:", dbtype = "duckdb") spec_table_sqlite <- db_tbl(table = specifications, dbname = ":memory:", dbtype = "sqlite") spec_table_duckdb <- db_tbl(table = specifications, dbname = ":memory:", dbtype = "duckdb") check_missing_in_column <- function(tbl, has_missing, not_missing, col_names) { for (col in col_names) { missing_in_bin <- any(!( tbl %>% dplyr::filter(col_name == .env$col) %>% dplyr::pull(value) %>% is.na() )) if (col %in% has_missing) { expect_true(missing_in_bin) } else { expect_false(missing_in_bin) } } } test_that("the `get_table_column_names()` function works", { expect_equal( get_table_column_names(small_table), c("date_time", "date", "a", "b", "c", "d", "e", "f") ) expect_equal( get_table_column_names(small_table_sqlite), c("date_time", "date", "a", "b", "c", "d", "e", "f") ) expect_equal( get_table_column_names(small_table_duckdb), c("date_time", "date", "a", "b", "c", "d", "e", "f") ) }) test_that("the `get_table_total_rows()` function works", { expect_equal(get_table_total_rows(small_table), 13) expect_equal(get_table_total_rows(small_table_sqlite), 13) expect_equal(get_table_total_rows(small_table_duckdb), 13) }) test_that("the `get_table_total_columns()` function works", { expect_equal(get_table_total_columns(small_table), 8) expect_equal(get_table_total_columns(small_table_sqlite), 8) expect_equal(get_table_total_columns(small_table_duckdb), 8) }) test_that("the `get_table_total_missing_values()` function works", { expect_equal(get_table_total_missing_values(specifications), 12) expect_equal(get_table_total_missing_values(spec_table_sqlite), 12) expect_equal(get_table_total_missing_values(spec_table_duckdb), 12) }) test_that("the `get_table_total_distinct_rows()` function works", { expect_equal(get_table_total_distinct_rows(small_table), 12) expect_equal(get_table_total_distinct_rows(small_table_sqlite), 12) expect_equal(get_table_total_distinct_rows(small_table_duckdb), 12) expect_equal(get_table_total_distinct_rows(specifications), 8) expect_equal(get_table_total_distinct_rows(spec_table_sqlite), 8) expect_equal(get_table_total_distinct_rows(spec_table_duckdb), 8) }) test_that("the `get_table_column_distinct_rows()` function works", { small_table_c <- small_table %>% dplyr::select(c) small_table_sqlite_c <- small_table_sqlite %>% dplyr::select(c) small_table_duckdb_c <- small_table_duckdb %>% dplyr::select(c) expect_equal(get_table_column_distinct_rows(small_table_c), 7) expect_equal(get_table_column_distinct_rows(small_table_sqlite_c), 7) expect_equal(get_table_column_distinct_rows(small_table_duckdb_c), 7) }) test_that("the `get_table_column_na_values()` function works", { small_table_c <- small_table %>% dplyr::select(c) small_table_sqlite_c <- small_table_sqlite %>% dplyr::select(c) small_table_duckdb_c <- small_table_duckdb %>% dplyr::select(c) expect_equal(get_table_column_na_values(small_table_c), 2) expect_equal(get_table_column_na_values(small_table_sqlite_c), 2) expect_equal(get_table_column_na_values(small_table_duckdb_c), 2) }) test_that("the `get_table_column_inf_values()` function works", { tbl_inf <- dplyr::tibble(a = c(2.3, NA, 6.1, 0.8, Inf, 5.2, -Inf, Inf, 3.2, -Inf)) small_table_sqlite_c <- small_table_sqlite %>% dplyr::select(c) small_table_duckdb_c <- small_table_duckdb %>% dplyr::select(c) expect_equal(get_table_column_inf_values(tbl_inf), 4) expect_equal(get_table_column_inf_values(small_table_sqlite_c), 0) expect_equal(get_table_column_inf_values(small_table_duckdb_c), 0) }) test_that("the `get_table_column_summary()` function works", { small_table_c <- small_table %>% dplyr::select(c) small_table_sqlite_c <- small_table_sqlite %>% dplyr::select(c) small_table_duckdb_c <- small_table_duckdb %>% dplyr::select(c) expect_equal( get_table_column_summary(small_table_c), dplyr::tibble(mean = 5.73, min = 2, max = 9) ) expect_equal( get_table_column_summary(small_table_sqlite_c), dplyr::tibble(mean = 5.73, min = 2, max = 9) ) expect_equal( get_table_column_summary(small_table_duckdb_c), dplyr::tibble(mean = 5.73, min = 2, max = 9) ) }) test_that("the `get_df_column_qtile_stats()` function works for data frames", { small_table_d <- small_table %>% dplyr::select(d) expected_qtile_stats <- list( min = 108.34, p05 = 213.7, q_1 = 837.93, med = 1035.64, q_3 = 3291.03, p95 = 6335.44, max = 9999.99, iqr = 2453.1, range = 9891.65 ) expect_equal( get_df_column_qtile_stats(small_table_d), expected_qtile_stats ) }) test_that("the `get_dbi_column_qtile_stats()` function works for `tbl_dbi` data", { small_table_sqlite_d <- small_table_sqlite %>% dplyr::select(d) small_table_duckdb_d <- small_table_duckdb %>% dplyr::select(d) expected_qtile_stats <- list( min = 108.34, p05 = 108.34, q_1 = 833.98, med = 843.34, q_3 = 2343.23, p95 = 3892.4, max = 9999.99, iqr = 1509.25, range = 9891.65 ) expect_equal( get_dbi_column_qtile_stats(small_table_sqlite_d), expected_qtile_stats ) expect_equal( get_dbi_column_qtile_stats(small_table_duckdb_d), expected_qtile_stats ) }) test_that("the `get_dbi_column_mean()` function works for `tbl_dbi` data", { small_table_sqlite_c <- small_table_sqlite %>% dplyr::select(c) small_table_duckdb_c <- small_table_duckdb %>% dplyr::select(c) small_table_sqlite_d <- small_table_sqlite %>% dplyr::select(d) small_table_duckdb_d <- small_table_duckdb %>% dplyr::select(d) expect_equal(get_dbi_column_mean(small_table_sqlite_c), 5.727, tolerance = 0.1) expect_equal(get_dbi_column_mean(small_table_duckdb_c), 5.727, tolerance = 0.1) expect_equal(get_dbi_column_mean(small_table_sqlite_d), 2304.702, tolerance = 0.1) expect_equal(get_dbi_column_mean(small_table_duckdb_d), 2304.702, tolerance = 0.1) }) test_that("the `get_dbi_column_variance()` function works for `tbl_dbi` data", { small_table_sqlite_c <- small_table_sqlite %>% dplyr::select(c) small_table_duckdb_c <- small_table_duckdb %>% dplyr::select(c) small_table_sqlite_d <- small_table_sqlite %>% dplyr::select(d) small_table_duckdb_d <- small_table_duckdb %>% dplyr::select(d) c_mean <- 5.727 d_mean <- 2304.702 expect_equal(get_dbi_column_variance(small_table_sqlite_c, mean_value = c_mean), 6.74, tolerance = 0.1) expect_equal(get_dbi_column_variance(small_table_duckdb_c, mean_value = c_mean), 6.74, tolerance = 0.1) expect_equal(get_dbi_column_variance(small_table_sqlite_d, mean_value = d_mean), 6391448, tolerance = 1) expect_equal(get_dbi_column_variance(small_table_duckdb_d, mean_value = d_mean), 6391448, tolerance = 1) }) test_that("the `get_table_column_histogram()` function works", { small_table_f <- small_table %>% dplyr::select(f) small_table_sqlite_f <- small_table_sqlite %>% dplyr::select(f) small_table_duckdb_f <- small_table_duckdb %>% dplyr::select(f) expect_s3_class(get_table_column_histogram(small_table_f, lang = "en", locale = "en"), c("gg", "ggplot")) expect_s3_class(get_table_column_histogram(small_table_sqlite_f, lang = "en", locale = "en"), c("gg", "ggplot")) expect_s3_class(get_table_column_histogram(small_table_duckdb_f, lang = "en", locale = "en"), c("gg", "ggplot")) }) test_that("the `get_tbl_df_missing_tbl()` function works", { missing_tbl_small_table <- get_tbl_df_missing_tbl(small_table) missing_tbl_diamonds <- get_tbl_df_missing_tbl(ggplot2::diamonds) missing_tbl_airquality <- get_tbl_df_missing_tbl(airquality) colnames_small_table <- colnames(small_table) has_missing <- "c" not_missing <- base::setdiff(colnames_small_table, has_missing) check_missing_in_column(missing_tbl_small_table, has_missing, not_missing, colnames_small_table) colnames_diamonds <- colnames(ggplot2::diamonds) has_missing <- "" not_missing <- colnames_diamonds check_missing_in_column(missing_tbl_diamonds, has_missing, not_missing, colnames_diamonds) colnames_diamonds <- colnames(airquality) has_missing <- c("Ozone", "Solar.R") not_missing <- base::setdiff(colnames_diamonds, has_missing) check_missing_in_column(missing_tbl_airquality, has_missing, not_missing, colnames_diamonds) }) test_that("the `get_tbl_dbi_missing_tbl()` function works", { missing_tbl_small_table_sqlite <- get_tbl_dbi_missing_tbl(small_table_sqlite) missing_tbl_small_table_duckdb <- get_tbl_dbi_missing_tbl(small_table_duckdb) missing_tbl_spec_table_sqlite <- get_tbl_dbi_missing_tbl(spec_table_sqlite) missing_tbl_spec_table_duckdb <- get_tbl_dbi_missing_tbl(spec_table_duckdb) colnames_small_table <- colnames(small_table) has_missing <- "c" not_missing <- base::setdiff(colnames_small_table, has_missing) check_missing_in_column(missing_tbl_small_table_sqlite, has_missing, not_missing, colnames_small_table) check_missing_in_column(missing_tbl_small_table_duckdb, has_missing, not_missing, colnames_small_table) colnames_specifications <- colnames(specifications) has_missing <- colnames_specifications not_missing <- "" check_missing_in_column(missing_tbl_spec_table_sqlite, has_missing, not_missing, colnames_specifications) check_missing_in_column(missing_tbl_spec_table_duckdb, has_missing, not_missing, colnames_specifications) }) test_that("the `get_missing_by_column_tbl()` function works", { missing_by_col_small_table <- get_missing_by_column_tbl(small_table) missing_by_col_small_table_sqlite <- get_missing_by_column_tbl(small_table_sqlite) missing_by_col_small_table_duckdb <- get_missing_by_column_tbl(small_table_duckdb) expect_equal(missing_by_col_small_table, missing_by_col_small_table_sqlite) expect_equal(missing_by_col_small_table, missing_by_col_small_table_duckdb) expect_equal( missing_by_col_small_table %>% dplyr::mutate(col_name = as.character(col_name)), dplyr::tibble( value = c(0, 0, 0, 0, 0.15, 0, 0, 0), col_num = 1:8, col_name = colnames(small_table) ) ) missing_by_col_spec_table <- get_missing_by_column_tbl(specifications) missing_by_col_spec_table_sqlite <- get_missing_by_column_tbl(spec_table_sqlite) missing_by_col_spec_table_duckdb <- get_missing_by_column_tbl(spec_table_duckdb) expect_equal(missing_by_col_spec_table, missing_by_col_spec_table_sqlite) expect_equal(missing_by_col_spec_table, missing_by_col_spec_table_duckdb) expect_equal( missing_by_col_spec_table %>% dplyr::mutate(col_name = as.character(col_name)), dplyr::tibble( value = rep(0.12, 12), col_num = 1:12, col_name = colnames(specifications) ) ) })
seq_mosaic <- function( x, panel = mosaic, type = c("joint", "conditional", "mutual", "markov", "saturated"), plots = 1:nf, vorder = 1:nf, k = NULL, ... ) { if (inherits(x, "data.frame") && "Freq" %in% colnames(x)) { x <- xtabs(Freq ~ ., data=x) } if (!inherits(x, c("table", "array"))) stop("not an xtabs, table, array or data.frame with a 'Freq' variable") nf <- length(dim(x)) x <- aperm(x, vorder) factors <- names(dimnames(x)) indices <- 1:nf type = match.arg(type) for (i in plots) { mtab <- margin.table(x, 1:i) df <- NULL if (i==1) { expected <- mtab expected[] <- sum(mtab) / length(mtab) df <- length(mtab)-1 model.string = paste("=", factors[1]) } else { expected <- switch(type, 'conditional' = conditional(i, mtab, with=if(is.null(k)) i else k), 'joint' = joint(i, mtab, with=if(is.null(k)) i else k), 'mutual' = mutual(i, mtab), 'markov' = markov(i, mtab, order=if(is.null(k)) 1 else k), 'saturated' = saturated(i, mtab) ) model.string <- loglin2string(expected, brackets=if (i<nf) '()' else '[]') } panel(mtab, expected=expected, df=df, main=model.string, ...) } }
"bugs.run" <- function(n.burnin, OpenBUGS.pgm, debug=FALSE, useWINE=FALSE, WINE=NULL, newWINE=TRUE, WINEPATH=NULL) { if(.Platform$OS.type == "windows" || useWINE){ bugsCall <- paste("\"", OpenBUGS.pgm, "\" /PAR \"", native2win(file.path(getwd(), "script.txt"), useWINE=useWINE, newWINE=newWINE, WINEPATH=WINEPATH), "\" /", sep="") if(!debug)bugsCall<-paste(bugsCall,"HEADLESS",sep="") if(useWINE) bugsCall <- paste(WINE, bugsCall) }else{ bugsCall <- paste(OpenBUGS.pgm, "<", "script.txt", ">", file.path(getwd(), "log.txt")) } if((.Platform$OS.type == "windows" || useWINE) && debug){ temp <- system(bugsCall,invisible=FALSE) }else temp <- system(bugsCall) if(temp == -1) stop("Error in bugs.run().") tmp <- scan("CODAchain1.txt", character(), quiet=TRUE, sep="\n") tmp <- tmp[1:min(100,length(tmp))] if(length(grep("OpenBUGS did not run correctly", tmp)) > 0) stop(paste("Look at the log file in ",getwd(), " and\ntry again with 'debug=TRUE' to figure out what went wrong within OpenBUGS.")) }
"test_models"
bed.merge.inds <- function(x1, x2) { ped <- rbind(x1@ped, x2@ped) w <- !duplicated( ped[,c("famid", "id")] ) ped <- ped[w,] w <- order(ped$famid, ped$id) ped <- ped[w,] x1_ids <- paste( x1@ped$famid, x1@ped$id, sep = rawToChar(as.raw(10)) ) x2_ids <- paste( x2@ped$famid, x2@ped$id, sep = rawToChar(as.raw(10)) ) ids <- paste( ped$famid, ped$id, sep = rawToChar(as.raw(10)) ) w1 <- match(ids, x1_ids, 0L) w2 <- match(ids, x2_ids, 0L) bed1 <- .Call('gg_extract_inds_indices', x1@bed, w1) bed2 <- .Call('gg_extract_inds_indices', x2@bed, w2) bed <- .Call("gg_bind_snps", PACKAGE = "gaston", list(bed1, bed2)) snps <- rbind(x1@snps, x2@snps) x <- new("bed.matrix", bed = bed, snps = snps, ped = ped, p = NULL, mu = NULL, sigma = NULL, standardize_p = FALSE, standardize_mu_sigma = FALSE ) if(getOption("gaston.auto.set.stats", TRUE)) x <- set.stats(x, verbose = getOption("gaston.verbose", TRUE)) x }
vcfR <- read.vcfR("~/Desktop/todiramphus.2021/populations.snps.vcf") vc<-vcfR[c(1:500000),c(1:101)] vc write.vcf(x = vc, file="~/Desktop/benchmarking.vcfs/benchmark.500K.vcf.gz") vc<-vc[sample(c(1:500000), 400000),] vc write.vcf(x = vc, file="~/Desktop/benchmarking.vcfs/benchmark.400K.vcf.gz") vc<-vc[sample(c(1:400000), 300000),] vc write.vcf(x = vc, file="~/Desktop/benchmarking.vcfs/benchmark.300K.vcf.gz") vc<-vc[sample(c(1:300000), 200000),] vc write.vcf(x = vc, file="~/Desktop/benchmarking.vcfs/benchmark.200K.vcf.gz") vc<-vc[sample(c(1:200000), 100000),] vc write.vcf(x = vc, file="~/Desktop/benchmarking.vcfs/benchmark.100K.vcf.gz") vc<-vc[sample(c(1:100000), 50000),] vc write.vcf(x = vc, file="~/Desktop/benchmarking.vcfs/benchmark.50K.vcf.gz") vc<-vc[sample(c(1:50000), 20000),] vc write.vcf(x = vc, file="~/Desktop/benchmarking.vcfs/benchmark.20K.vcf.gz") vc<-vc[sample(c(1:20000), 10000),] vc write.vcf(x = vc, file="~/Desktop/benchmarking.vcfs/benchmark.10K.vcf.gz")
add.rootedge <- function(t1,age){ t<-t1 t$edge <- t1$edge root<- max(t$edge)+1 mrca<-t$edge[1,1] t$edge <- rbind(c(root,mrca),t$edge) edgelength <- age-t$edge.length[1] t$edge.length <- c(edgelength,t$edge.length) t$tip.label <- paste("t", sample(t$Nnode+1), sep = "") t$Nnode<-t$Nnode+1 t }
rm(list = ls()) s <- search()[-1] s <- s[-match(c("package:base", "package:stats", "package:graphics", "package:grDevices", "package:utils", "package:datasets", "package:methods", "Autoloads"), s)] if (length(s) > 0) sapply(s, detach, character.only = TRUE) if (!file.exists("tables")) dir.create("tables") if (!file.exists("figures")) dir.create("figures") set.seed(290875) options(prompt = "R> ", continue = "+ ", width = 63, show.signif.stars = FALSE, SweaveHooks = list(leftpar = function() par(mai = par("mai") * c(1, 1.05, 1, 1)), bigleftpar = function() par(mai = par("mai") * c(1, 1.7, 1, 1)))) HSAURpkg <- require("HSAUR3") if (!HSAURpkg) stop("cannot load package ", sQuote("HSAUR3")) rm(HSAURpkg) a <- Sys.setlocale("LC_ALL", "C") book <- TRUE refs <- cbind(c("AItR", "DAGD", "SI", "CI", "ANOVA", "MLR", "GLM", "DE", "RP", "GAM", "SA", "ALDI", "ALDII", "SIMC", "MA", "PCA", "MDS", "CA"), 1:18) ch <- function(x) { ch <- refs[which(refs[,1] == x),] if (book) { return(paste("Chapter~\\\\ref{", ch[1], "}", sep = "")) } else { return(paste("Chapter~", ch[2], sep = "")) } } if (file.exists("deparse.R")) source("deparse.R") setHook(packageEvent("lattice", "attach"), function(...) { lattice.options(default.theme = function() standard.theme("pdf", color = FALSE)) }) book <- FALSE library("mgcv") library("mboost") library("rpart") library("wordcloud") plot(time ~ year, data = men1500m, xlab = "Year", ylab = "Winning time (sec)") men1500m1900 <- subset(men1500m, year >= 1900) men1500m_lm <- lm(time ~ year, data = men1500m1900) plot(time ~ year, data = men1500m1900, xlab = "Year", ylab = "Winning time (sec)") abline(men1500m_lm) x <- men1500m1900$year y <- men1500m1900$time men1500m_lowess <- lowess(x, y) plot(time ~ year, data = men1500m1900, xlab = "Year", ylab = "Winning time (sec)") lines(men1500m_lowess, lty = 2) men1500m_cubic <- gam(y ~ s(x, bs = "cr")) lines(x, predict(men1500m_cubic), lty = 3) men1500m_lm2 <- lm(time ~ year + I(year^2), data = men1500m1900) plot(time ~ year, data = men1500m1900, xlab = "Year", ylab = "Winning time (sec)") lines(men1500m1900$year, predict(men1500m_lm2)) predict(men1500m_lm, newdata = data.frame(year = c(2008, 2012)), interval = "confidence") predict(men1500m_lm2, newdata = data.frame(year = c(2008, 2012)), interval = "confidence") library("mboost") USair_boost <- gamboost(SO2 ~ ., data = USairpollution) USair_aic <- AIC(USair_boost) USair_aic USair_gam <- USair_boost[mstop(USair_aic)] layout(matrix(1:6, ncol = 3)) plot(USair_gam, ask = FALSE) SO2hat <- predict(USair_gam) SO2 <- USairpollution$SO2 plot(SO2hat, SO2 - SO2hat, type = "n", xlim = c(-20, max(SO2hat) * 1.1), ylim = range(SO2 - SO2hat) * c(2, 1)) textplot(SO2hat, SO2 - SO2hat, rownames(USairpollution), show.lines = FALSE, new = FALSE) abline(h = 0, lty = 2, col = "grey") layout(matrix(1:3, nrow = 1)) spineplot(Kyphosis ~ Age, data = kyphosis, ylevels = c("present", "absent")) spineplot(Kyphosis ~ Number, data = kyphosis, ylevels = c("present", "absent")) spineplot(Kyphosis ~ Start, data = kyphosis, ylevels = c("present", "absent")) (kyphosis_gam <- gam(Kyphosis ~ s(Age, bs = "cr") + s(Number, bs = "cr", k = 3) + s(Start, bs = "cr", k = 3), family = binomial, data = kyphosis)) trans <- function(x) binomial()$linkinv(x) layout(matrix(1:3, nrow = 1)) plot(kyphosis_gam, select = 1, shade = TRUE, trans = trans) plot(kyphosis_gam, select = 2, shade = TRUE, trans = trans) plot(kyphosis_gam, select = 3, shade = TRUE, trans = trans) data("womensrole", package = "HSAUR3") fm1 <- cbind(agree, disagree) ~ s(education, by = gender) womensrole_gam <- gam(fm1, data = womensrole, family = binomial()) layout(matrix(1:2, nrow = 1)) plot(womensrole_gam, select = 1, shade = TRUE) plot(womensrole_gam, select = 1, shade = TRUE) myplot <- function(role.fitted) { f <- womensrole$gender == "Female" plot(womensrole$education, role.fitted, type = "n", ylab = "Probability of agreeing", xlab = "Education", ylim = c(0,1)) lines(womensrole$education[!f], role.fitted[!f], lty = 1) lines(womensrole$education[f], role.fitted[f], lty = 2) lgtxt <- c("Fitted (Males)", "Fitted (Females)") legend("topright", lgtxt, lty = 1:2, bty = "n") y <- womensrole$agree / (womensrole$agree + womensrole$disagree) size <- womensrole$agree + womensrole$disagree size <- size - min(size) size <- (size / max(size)) * 3 + 1 text(womensrole$education, y, ifelse(f, "\\VE", "\\MA"), family = "HersheySerif", cex = size) } myplot(predict(womensrole_gam, type = "response"))
valid_names <- function(x) { x <- gsub('[\'\\"]', '', x) x <- gsub('[:\\$/\\]', '_', x) x <- gsub("[^0-9A-Za-z_]","" , x ,ignore.case = TRUE) x <- substr(x, start = 0, stop = 20) make.unique(x, sep = "_") }
prepare_path <- function(data, label, gp, params) { path <- dedup_path( x = as_inch(data$x, "x"), y = as_inch(data$y, "y"), id = data$id, line_x = as_inch(data$line_x, "x"), line_y = as_inch(data$line_y, "y") ) path <- split(path, path$id) singletons <- nrow_multi(path) == 1 if (any(singletons)) { width <- numapply(label, function(x) 1.2 * max(x$xmax, na.rm = TRUE)) path[singletons] <- Map(pathify, data = path[singletons], hjust = params$hjust[singletons], angle = params$angle, width = width[singletons], polar_x = list(params$polar_params$x), polar_y = list(params$polar_params$y), thet = list(params$polar_params$theta)) gp$lty[singletons] <- 0 } attr(path, "gp") <- gp return(path) } make_gap <- function( path, letters, gap = NA, padding = 0.05, vjust = 0.5, vjust_lim = c(0, 1) ) { padding <- as_inch(padding) if (is.unit(vjust)) { vjust <- rep_len(0.5, length(vjust)) } trim <- vjust >= vjust_lim[1] & vjust <= vjust_lim[2] trim <- if (!is.na(gap)) rep(gap, length(trim)) else trim if (!any(trim)) { path$section <- "all" path$x <- path$line_x path$y <- path$line_y path$length <- arclength_from_xy(path$x, path$y, path$id) } else { path$id <- discretise(path$id) path$length <- path$length %||% arclength_from_xy(path$x, path$y, path$id) path$line_length <- arclength_from_xy(path$line_x, path$line_y, path$id) lefts <- gapply(letters$left, letters$id, min, numeric(1)) rights <- gapply(letters$right, letters$id, max, numeric(1)) ranges <- rbind(lefts, rights) path_max <- gapply(path$length, path$id, max, numeric(1)) trim <- rep_len(trim, length(path_max)) mins <- pmax(0, ranges[1, ] - padding) maxs <- pmin(path_max, ranges[2, ] + padding) sumlen <- c(0, path_max[-length(path_max)]) sumlen <- cumsum(sumlen + seq_along(path_max) - 1) mins <- mins + sumlen maxs <- maxs + sumlen path$length <- path$length + sumlen[path$id] section <- character(nrow(path)) section[path$length <= mins[path$id]] <- "pre" section[path$length >= maxs[path$id]] <- "post" section[!trim[path$id]] <- "all" ipol <- c(mins[trim], maxs[trim]) trim_xy <- approx_multi(x = path$length, y = path[c("line_x", "line_y", "line_length")], xout = ipol) path <- data_frame( x = c(path$line_x, trim_xy$line_x), y = c(path$line_y, trim_xy$line_y), id = c(path$id, rep(which(trim), 2L)), length = c(path$line_length, trim_xy$line_length), section = c(section, rep(c("pre", "post"), each = sum(trim))) )[order(c(path$line_length, trim_xy$line_length)), , drop = FALSE] path <- path[order(path$id), , drop = FALSE] path <- path[path$section != "", , drop = FALSE] group <- paste0(path$id, path$section) len <- ave(path$length, group, FUN = function(x) diff(range(x))) path <- path[len > 1e-3, ] sect <- ave(path$section, path$id, FUN = function(x) length(unique(x))) path$section[sect == "1"] <- "all" } if (!nrow(path)) { path$new_id <- integer() path$start <- logical() return(path) } path$new_id <- group_id(path, c("id", "section")) path$start <- c(TRUE, path$new_id[-1] != path$new_id[-length(path$new_id)]) return(path) } dedup_path <- function( x, y, id, line_x, line_y, tolerance = 1000 * .Machine$double.eps ) { vecs <- data_frame(x = interp_na(x), y = interp_na(y), id = id, line_x = line_x, line_y = line_y) lens <- lengths(vecs) n <- max(lengths(vecs)) vecs[lens != n] <- lapply(vecs[lens != n], rep_len, length.out = n) dups <- vapply(vecs, function(x) abs(x[-1] - x[-length(x)]) < tolerance, logical(n - 1)) dups <- if (is.null(dim(dups))) dups[1:3] else dups[, 1:3] if (n > 2) { keep <- c(TRUE, rowSums(dups) < 3L) } else { keep <- c(TRUE, sum(dups) < 3L) } vecs <- vecs[keep, , drop = FALSE] vecs[complete.cases(vecs), ] } pathify <- function( data, hjust, angle, width, polar_x = NULL, polar_y = NULL, thet = NULL ) { angle <- pi * angle / 180 multi_seq <- Vectorize(seq.default) if (!is.null(polar_x) & !is.null(polar_y) & !is.null(thet)) { polar_x <- as_inch(polar_x, "x") polar_y <- as_inch(polar_y, "y") angle <- angle - (as.numeric(thet == "y") * pi / 2) r <- sqrt((data$x - polar_x)^2 + (data$y - polar_y)^2) width <- width / r theta <- atan2(data$y - polar_y, data$x - polar_x) theta_min <- theta + cos(angle + pi) * width * hjust theta_max <- theta + cos(angle) * width * (1 - hjust) r_min <- r + sin(angle + pi) * width * hjust r_max <- r + sin(angle) * width * (1 - hjust) theta <- c(multi_seq(theta_min, theta_max, length.out = 100)) r <- c(multi_seq(r_min, r_max, length.out = 100)) x <- polar_x + r * cos(theta) y <- polar_y + r * sin(theta) } else { xmin <- data$x + cos(angle + pi) * width * hjust xmax <- data$x + cos(angle) * width * (1 - hjust) ymin <- data$y + sin(angle + pi) * width * hjust ymax <- data$y + sin(angle) * width * (1 - hjust) x <- c(multi_seq(xmin, xmax, length.out = 100)) y <- c(multi_seq(ymin, ymax, length.out = 100)) } data <- data[rep(seq(nrow(data)), each = 100), ] data$x <- x data$y <- y data$line_x <- x data$line_y <- y data } tailor_arrow <- function(data, arrow) { if (is.null(arrow)) { return(arrow) } keep <- !duplicated(data$new_id) sides <- data$section[keep] id <- data$id[keep] arrow[] <- lapply(arrow, function(x) { x[pmin(id, length(x))] }) ends <- arrow$ends lens <- arrow$length lens[ends == 2 & sides == "pre"] <- unit(0, "pt") lens[ends == 1 & sides == "post"] <- unit(0, "pt") ends[ends == 3 & sides == "pre"] <- 1L ends[ends == 3 & sides == "post"] <- 2L arrow$ends <- ends arrow$length <- lens arrow } add_path_grob <- function(grob, data, text, gp, params, arrow = NULL) { has_line <- !all((gp$lty %||% 1) %in% c("0", "blank", NA)) is_opaque <- !all((gp$col %||% 1) %in% c(NA, "transparent")) if (has_line && is_opaque) { data <- rbind_dfs(data) data <- make_gap( data, text, vjust = params$vjust %||% 0.5, gap = params$gap %||% NA, padding = params$padding %||% 0.05 ) arrow <- tailor_arrow(data, arrow) if (nrow(data) > 1) { gp <- recycle_gp(gp, `[`, i = data$id[data$start]) gp$fill <- gp$col grob <- addGrob( grob, polylineGrob( x = data$x, y = data$y, id = data$new_id, gp = gp, default.units = "inches", arrow = arrow ) ) } } return(grob) }
gl.keep.ind <- function(x, ind.list, recalc=FALSE, mono.rm=FALSE, verbose=NULL){ funname <- match.call()[[1]] build <- "Jacob" if (is.null(verbose)){ if(!is.null(x@other$verbose)){ verbose <- x@other$verbose } else { verbose <- 2 } } if (verbose < 0 | verbose > 5){ cat(paste(" Warning: Parameter 'verbose' must be an integer between 0 [silent] and 5 [full report], set to 2\n")) verbose <- 2 } if (verbose >= 1){ if(verbose==5){ cat("Starting",funname,"[ Build =",build,"]\n") } else { cat("Starting",funname,"\n") } } if(class(x)!="genlight") { stop("Fatal Error: genlight object required!\n") } if (all(x@ploidy == 1)){ if (verbose >= 2){cat(" Processing Presence/Absence (SilicoDArT) data\n")} data.type <- "SilicoDArT" } else if (all(x@ploidy == 2)){ if (verbose >= 2){cat(" Processing a SNP dataset\n")} data.type <- "SNP" } else { stop("Fatal Error: Ploidy must be universally 1 (fragment P/A data) or 2 (SNP data)") } for (case in ind.list){ if (!(case%in%indNames(x))){ cat(" Warning: Listed individual",case,"not present in the dataset -- ignored\n") ind.list <- ind.list[!(ind.list==case)] } } if (length(ind.list) == 0) { stop(" Fatal Error: no individuals listed to keep!\n") } if (verbose >= 2) { cat(" Deleteing all but the listed individuals", ind.list, "\n") } x <- x[x$ind.names%in%ind.list] x@other$loc.metrics.flags$monomorphs == FALSE if(mono.rm){ if(verbose >= 2){cat(" Deleting monomorphic loc\n")} x <- gl.filter.monomorphs(x,verbose=0) } if (x@other$loc.metrics.flags$monomorphs == FALSE){ if (verbose >= 2){ cat(" Warning: Resultant dataset may contain monomorphic loci\n") } } if (recalc) { x <- gl.recalc.metrics(x,verbose=0) if(verbose >= 2){cat(" Recalculating locus metrics\n")} } else { if(verbose >= 2){ cat(" Locus metrics not recalculated\n") x <- utils.reset.flags(x,verbose=0) } } if (verbose >= 3) { cat(" Summary of recoded dataset\n") cat(paste(" No. of loci:",nLoc(x),"\n")) cat(paste(" No. of individuals:", nInd(x),"\n")) cat(paste(" No. of populations:", nPop(x),"\n")) } nh <- length(x@other$history) x@other$history[[nh + 1]] <- match.call() if (verbose > 0) { cat("Completed: gl.keep.ind\n") } return(x) }
context("dutyCycle") test_that("Correct value is output", { d <- data2Wave(c(rep_len(0,22050),rep_len(1,22050)), remove.offset=FALSE, normalise=FALSE) expect_equal(dutyCycle(d, output="unit", normalise=FALSE), 0.5) }) test_that("Corect value is output in percantage mode", { d <- data2Wave(c(rep_len(0,22050),rep_len(1,22050)), remove.offset=FALSE, normalise=FALSE) expect_equal(dutyCycle(d, output="percent", normalise=FALSE), 50) })
context("Testing rtcc2") test_that("rtcc2", { data(metadata) data(group_information) data(table_presence_absence) RNGversion("3.5") set.seed(999999) expect_equal(round(sum(rtcc2(group_information, table_presence_absence, metadata, group_information$sums, 9, 12, 13, 2, 2, 1, model = 1)), digits = 4), 973.4132) })
context("Testing information_arma") test_that("bogus arguments throw error",{ expect_error(information_arma(NA, Inf)) }) test_that("output of information_arma is correct",{ mat <- information_arma(c(0.9, 0.45)) expect_is(mat, "matrix") expect_equal(mat, matrix(-c(0.7474095,1.2230338,1.2230338,0.7474095), 2, 2), tolerance = 1e-5) mat <- information_arma(theta = c(0.9, 0.45)) expect_is(mat, "matrix") expect_equal(mat, matrix(c(2.039740,-1.266045,-1.266045,2.039740), 2, 2), tolerance = 1e-5) mat <- information_arma(0.9,0.45) expect_is(mat, "matrix") expect_equal(mat, matrix(c(5.2631579,-0.7117438,-0.7117438,1.2539185), 2, 2), tolerance = 1e-5) })
mean.center <- function(m){ if (!('matrix' %in% class(m))) m <- as.matrix(m) for (i in 1:ncol(m)) m[,i] <- m[,i] - mean(m[,i]) return(m) }
pkg_ref_cache.source_control_url <- function(x, name, ...) { grep( "(github\\.com|bitbucket\\.org|gitlab\\.com)", x$website_urls, value = TRUE) }
knit_concord = new_defaults(list( inlines = NULL, outlines = NULL, infile = NULL, outfile = NULL )) concord_mode = function() { opts_knit$get('concordance') && !child_mode() && out_format(c('latex', 'sweave', 'listings')) } current_lines = function(i) { n = knit_concord$get('inlines') n1 = sum(head(n, i)); n0 = n1 - n[i] + 2 c(min(n0, n1), n1) } concord_gen = function(infile, outfile) { if (!concord_mode()) return() i = knit_concord$get('inlines'); o = knit_concord$get('outlines') if (is.null(i) || is.null(o)) { warning('cannot generate concordance due to incomplete line numbers') return() } stopifnot(length(i) == length(o)) steps = NULL for (k in seq_along(i)) { steps = c(steps, if (o[k] >= i[k]) { rep(c(1L, 0L), c(i[k], o[k] - i[k])) } else { c(rep(1L, o[k] - 1L), i[k] - o[k] + 1L) }) } vals = rle(steps) vals = c(1L, as.numeric(rbind(vals$lengths, vals$values))) concordance = paste(strwrap(paste(vals, collapse = ' ')), collapse = ' %\n') confile = paste(sans_ext(outfile), 'concordance.tex', sep = '-') cat('\\Sconcordance{concordance:', outfile, ':', infile, ':%\n', concordance, '}\n', sep = '', file = confile) }
variableboxes <- setRefClass( Class = "variableboxes", fields = c("variable"), contains = c("gparts_base"), methods = list( front = function(top, types, titles, initialSelection = FALSE, modes = "default") { if (length(types) != length(titles)) { error("length(types) != length(titles)") } else { length <<- length(types) } if (length(modes) == 1) { if (modes == "default") { modes <- lapply(1:length, function(x) "single") } } if (length(types) != length(modes)) { error("length(types) != length(modes)") } if (length(initialSelection) == 1) { initialSelection <- lapply(1:length, function(x) initialSelection) } else if (length(initialSelection) != length) { error("length(initialSelection) != length(types)") } frame <<- tkframe(top) variable <<- lapply(1:length, function(i, types, modes, initialSelection, titles) { variableListBox( frame, variableList = unlist(types[i]), selectmode = unlist(modes[i]), initialSelection = unlist(initialSelection[i]), title = unlist(titles[i]) ) }, types, modes, initialSelection, titles ) back_list <<- NULL for (i in 1:length) { back_list <<- c(back_list, list(variable[[i]]$frame)) } return() } ) ) NULL
tau2theta <- function(tau, beta) { stopifnot(is.numeric(beta), is.numeric(tau)) theta <- list(beta = beta, alpha = 1, gamma = 0, delta = 0) if (!is.na(tau["alpha"])) { theta$alpha <- tau["alpha"] } if (!is.na(tau["delta"])) { theta$delta <- tau["delta"] } if (any(!is.na(tau[c("delta_l", "delta_r")]))) { theta$delta <- c(tau["delta_l"], tau["delta_r"]) names(theta$delta) <- c("delta_l", "delta_r") } if (!is.na(tau["gamma"])) { theta$gamma <- tau["gamma"] } theta <- complete_theta(theta) return(theta) }
rowMaxs.sirt <- function(matr){ rowMaxsCPP_source( matr ) } rowMins.sirt <- function(matr){ matr2 <- - matr res2 <- rowMaxs.sirt( matr2 ) res <- list( "minval"=- res2$maxval, "minind"=res2$maxind ) return(res) } rowCumsums.sirt <- function(matr){ rowCumsums2_source( matr ) } colCumsums.sirt <- function(matr){ t( rowCumsums.sirt( t(matr) ) ) } rowIntervalIndex.sirt <- function(matr,rn){ interval_index_C( matr, rn) } rowKSmallest.sirt <- function( matr, K, break.ties=TRUE){ M1 <- matr N1 <- dim(M1)[1] ; N2 <- dim(M1)[2] rM1 <- matrix( round( stats::runif( N1*N2 ) ), N1, N2 ) if ( ! break.ties ){ rM1 <- 0*rM1 } indexmatr <- matrix( 1:N2, N1, N2, byrow=TRUE ) a1 <- rowKSmallest_C( matr, K, indexmatr, rM1) return(a1) } rowKSmallest2.sirt <- function(matr, K ){ Nmis <- nrow(matr) disty <- matr donors <- K indvec <- 1:Nmis M1 <- max(disty)+1 smallval <- donor.ind <- matrix( 0, nrow=Nmis, ncol=donors ) res1 <- rowMins.sirt(matr=disty) donor.ind[,1] <- res1$minind smallval[,1] <- res1$minval for (ii in 2:donors){ disty[ cbind(indvec, donor.ind[,ii-1] ) ] <- M1 res1 <- rowMins.sirt(matr=disty) donor.ind[,ii] <- res1$minind smallval[,ii] <- res1$minval } res <- list( "smallval"=smallval, "smallind"=donor.ind ) return(res) }
reglca_mstep_item_parameters <- function(I, n.ik, N.ik, h, mstep_iter, conv, regular_lam, regular_type, cd_steps, item_probs, max_increment, iter, G, fac=1.02, prob_min=0, est_type="CD", xsi=NULL) { penalty <- rep(0,I) n_par <- rep(0,I) n_reg <- 0 n_reg_item <- rep(0,I) nclasses <- ncol(item_probs) expected_loglike <- rep(0,I) opt_fct_item_sum <- rep(0,I) bounds <- c( prob_min, 1-prob_min) if (G>1){ ND <- dim(n.ik) n.ik0 <- n.ik N.ik0 <- N.ik n.ik <- array( 0, dim=ND[1:3] ) N.ik <- matrix( 0, nrow=ND[1], ncol=ND[2] ) for (gg in 1:G){ n.ik <- n.ik + n.ik0[,,,gg] N.ik <- N.ik + N.ik0[,,gg] } } item_probs0 <- item_probs for (ii in 1:I){ freq <- n.ik[,ii,2] / N.ik[,ii] pi_class <- cdm_sumnorm(N.ik[,ii]) res <- reglca_fit_probabilities( freq=freq, pi_class=pi_class, h=h, maxit=mstep_iter, conv=conv, verbose=FALSE, parm_init=NULL, lambda=regular_lam, regular_type=regular_type, cd_steps=cd_steps, max_increment=max_increment, prob_min=prob_min, ii=ii, iter=iter, xsi=xsi, est_type=est_type) expected_loglike[ii] <- res$ll opt_fct_item_sum[ii] <- res$ll + res$pen incr <- res$probs - item_probs[ii,] incr <- cdm_trim_increment( increment=incr, max.increment=max_increment, type=1 ) item_probs[ii,] <- item_probs[ii,] + incr item_probs[ii,] <- cdm_squeeze( x=item_probs[ii,], bounds=bounds) penalty[ii] <- sum(N.ik[,ii]) * res$pen n_par[ii] <- res$n_par n_reg_item[ii] <- nclasses - res$n_par n_reg <- n_reg + nclasses - res$n_par } penalty <- sum(penalty) n_par <- sum(n_par) opt_fct_item_sum <- sum(opt_fct_item_sum) max_increment <- min( max_increment, max( abs( item_probs - item_probs0 ) ) ) / fac res <- list( item_probs=item_probs, penalty=penalty, n_par=n_par, n_reg=n_reg, max_increment=max_increment, n_reg_item=n_reg_item, opt_fct_item_sum=opt_fct_item_sum) return(res) }
`hbrr.integrate2.rhoeq1` <- function(MU,V,A=c(1,1),...){ if (V[1,1]!=V[2,2] | MU[1]!=MU[2]){ stop("when rho=1, then V[1,1] must equal V[2,2], and MU[1] must equal MU[2]") } hb.x<-function(x){ out<-(1/(1+10^(A[1]*x)))*(1/(1+10^(A[2]*x)))*dnorm(x,mean=MU[1],sd=sqrt(V[1,1])) return(out) } out<-integrate(hb.x,-Inf,Inf,...)$value return(out) }
isTRUE <- function(x){ is.logical(x) && length(x) == 1L && !is.na(x) && x } if (!exists("isFALSE", mode = "function", envir = baseenv())) { isFALSE <- function(x){ is.logical(x) && length(x) == 1L && !is.na(x) && !x } } tinytest <- function(result, call , trace= NULL , diff = NA_character_ , short= c(NA_character_,"data","attr","xcpt", "envv","wdir","file","lcle") , info = NA_character_ , file = NA_character_ , fst = NA_integer_ , lst = NA_integer_ ,...){ short <- match.arg(short) structure(result , class = "tinytest" , call = call , trace = trace , diff = diff , short = short , info = info , file = file , fst = fst , lst = lst , ...) } na_str <- function(x) if ( is.na(x) ) "" else as.character(x) oneline <- function(x) sub("\\n.+","...",x) indent <- function(x, with=" "){ if (is.na(x)) "" else gsub("\\n *",paste0("\n",with),paste0(with,sub("^ +","",x))) } lineformat <- function(x){ if ( is.na(x) ) "" else sprintf("%d",x) } has_call <- function(call, x){ attributes(x) <- NULL attributes(call) <- NULL identical(x,call) || length(x) > 1 && any(sapply(x, has_call, call)) } format.tinytest <- function(x,type=c("long","short"), ...){ type <- match.arg(type) d <- attributes(x) i <- tryCatch(sapply(d$trace, has_call, d$call), error=function(e) NULL) need_trace <- any(i) && all(i < length(d$trace)) call <- if( !need_trace ){ paste0(deparse(d$call, control=NULL), collapse="\n") } else { i1 <- which(i)[length(which(i))] j <- seq(i1,length(d$trace)) paste0(sapply(d$trace[j], deparse, control=NULL), collapse="\n-->") } fst <- lineformat(d$fst, ...) lst <- lineformat(d$lst, ...) file <- na_str(d$file) short <- na_str(d$short) diff <- d$diff info <- na_str(d$info) result <- if (isTRUE(x)) "PASSED " else if (isFALSE(x)) sprintf("FAILED[%s]",short) else if (is.na(x) ) sprintf("SIDEFX[%s]",short) longfmt <- "----- %s: %s<%s--%s>\n%s" if (type == "short"){ sprintf("%s: %s<%s--%s> %s", result, basename(file), fst, lst, oneline(call)) } else { str <- sprintf(longfmt, result, file, fst, lst , indent(call, with=" call| ")) if (isFALSE(x)||is.na(x)) str <- paste0(str, "\n", indent(diff, with=" diff| ")) if (!is.na(d$info)) str <- paste0(str, "\n", indent(info, with=" info| ")) str } } print.tinytest <- function(x,...){ cat(format.tinytest(x,...),"\n") } is_atomic <- function(x){ inherits(x,"POSIXct") || ( length(class(x)) == 1 && class(x) %in% c( "character" , "logical" , "factor" , "ordered" , "integer" , "numeric" , "complex") ) } is_scalar <- function(x){ length(x) == 1 && is_atomic(x) } longdiff <- function(current, target, alt){ equivalent_data <- all.equal(target, current , check.attributes=FALSE , use.names=FALSE) if ( identical(class(current), class(target)) && is_scalar(current) && is_scalar(target) ){ if (!isTRUE(equivalent_data)){ sprintf("Expected '%s', got '%s'", target, current) } else { "Attributes differ" } } else if (isTRUE(alt) && is.environment(current)){ "Equal environment objects, but with different memory location" } else { paste0(" ", alt, collapse="\n") } } shortdiff <- function(current, target, ...){ equivalent_data <- all.equal(target, current , check.attributes=FALSE , use.names=FALSE,...) if (isTRUE(equivalent_data)) "attr" else "data" } expect_equal <- function(current, target, tolerance = sqrt(.Machine$double.eps), info=NA_character_, ...){ check <- all.equal(target, current, tolerance=tolerance, ...) equal <- isTRUE(check) diff <- if (equal) NA_character_ else longdiff( current, target, check) short <- if (equal) NA_character_ else shortdiff(current, target, tolerance=tolerance) tinytest(result = equal, call = sys.call(sys.parent(1)), diff=diff, short=short, info=info) } expect_match <- function(current, pattern, info=NA_character_, ...){ result <- grepl(pattern, current, ...) out <- isTRUE(all(result)) diff <- if (out){ NA_character_ } else { if (length(current)==1){ sprintf("Expected string that matches '%s', got '%s'.", pattern, current) } else { sprintf("Not all strings match pattern '%s', for example element [%d]: '%s'" , pattern, which(!result)[1], current[which(!result)[1]]) } } short <- if (out) NA_character_ else "data" tinytest(result=out, call=sys.call(sys.parent(1)), diff=diff, short=short, info=info) } expect_identical <- function(current, target, info=NA_character_){ result <- identical(current, target) diff <- if (result) NA_character_ else longdiff(current, target, all.equal(target, current, check.attributes=TRUE)) short <- if (result) NA_character_ else shortdiff(current, target, tolerance=0) tinytest(result=result, call=sys.call(sys.parent(1)), diff=diff , short=short, info=info) } expect_equivalent <- function(current, target, tolerance = sqrt(.Machine$double.eps) , info=NA_character_, ...){ out <- expect_equal(current, target , check.attributes=FALSE,use.names=FALSE , tolerance=tolerance, info=info, ...) attr(out, 'call') <- sys.call(sys.parent(1)) out } expect_true <- function(current, info=NA_character_){ result <- isTRUE(current) call <- sys.call(sys.parent(1)) if (!result){ this <- if ( isFALSE(current) ) "FALSE" else if ( length(current) == 1 && is.na(current)) "NA" else if ( is.logical(current)) sprintf("'logical' of length %d",length(current)) else sprintf("object of class '%s'",class(current)) diff <- sprintf("Expected TRUE, got %s", this) short <- shortdiff(TRUE, FALSE) tinytest(result, call=call,diff=diff, short=short, info=info) } else { tinytest(result, call = sys.call(sys.parent(1)), info=info) } } expect_false <- function(current, info=NA_character_){ result <- isFALSE(current) call <- sys.call(sys.parent(1)) if (!result){ this <- if ( isTRUE(current) ) "TRUE" else if (length(current) == 1 && is.na(current)) "NA" else if (is.logical(current)) sprintf("'logical' of length %d",length(current)) else sprintf("object of class '%s'",class(current)) diff <- sprintf("Expected FALSE, got %s", this) short <- shortdiff(TRUE, FALSE) tinytest(result, call=call,diff=diff, short=short, info=info) } else { tinytest(result, call = sys.call(sys.parent(1)), info=info) } } expect_silent <- function(current, quiet=TRUE, info=NA_character_){ has_nullfile <- exists("nullfile") if (quiet){ dumpfile <- if(has_nullfile) do.call("nullfile", list()) else tempfile() sink(dumpfile) } on.exit({ if (quiet){ sink(NULL) if (!has_nullfile) unlink(dumpfile) } }) result <- TRUE msg <- "" type <- "none" tryCatch(current , error = function(e){ result <<- FALSE msg <<- e$message type <<- "An error" } , warning = function(w){ result <<- FALSE msg <<- w$message type <<- "A warning" } ) call <- sys.call(sys.parent(1)) diff <- if (msg != ""){ sprintf("Execution was not silent. %s was thrown with message\n '%s'",type,msg) } else { NA_character_ } tinytest(result , call = sys.call(sys.parent(1)) , short = if (result) NA_character_ else "xcpt" , diff = diff , info = info ) } expect_null <- function(current, info=NA_character_){ call <- sys.call(sys.parent(1)) if (is.null(current)){ tinytest(TRUE, call=call, info=info) } else { tinytest(FALSE, call=call, short="data" , diff = sprintf("Expected NULL, got '%s'", paste(class(current), collapse=", ")) , info = info ) } } expect_inherits <- function(current, class, info=NA_character_){ call <- sys.call(sys.parent(1)) res <- inherits(current, class) if (isTRUE(res)){ tinytest(TRUE, call=call, info=info) } else { tinytest(FALSE, call=call, short="attr" , diff = sprintf("Expected object of class %s, got %s" , paste0("<", paste(class,collapse=", "),">") , paste0("<", paste(class(current), collapse=", "),">")) , info=info) } } expect_error <- function(current, pattern=".*", class="error", info=NA_character_, ...){ result <- FALSE diff <- "No error" tryCatch(current, error=function(e){ matches <- grepl(pattern, e$message, ...) isclass <- inherits(e, class) if (matches && isclass){ result <<- TRUE } else if (!isclass){ diff <<- sprintf("Error of class '%s', does not inherit from '%s'" , paste(class(e), collapse=", "), class) } else if (!matches){ diff <<- sprintf("The error message:\n '%s'\n does not match pattern '%s'" , e$message, pattern) } }) tinytest(result, call = sys.call(sys.parent(1)) , short= if(result) NA_character_ else "xcpt" , diff = if(result) NA_character_ else diff , info = info) } first_n <- function(L, n=3){ i <- seq_len(min(length(L),n)) msgcls <- sapply(L[i], function(m) paste(class(m), collapse=", ")) maintype <- sapply(L[i], function(m){ if ( inherits(m, "message") ) "Message" else if ( inherits(m, "warning") ) "Warning" else if ( inherits(m, "error") ) "Error" else "Condition" }) msgtxt <- sub("\\n$","", sapply(L[i], function(m) m$message)) out <- sprintf("%s %d of class <%s>:\n '%s'",maintype, i, msgcls, msgtxt) paste(out, collapse="\n") } expect_warning <- function(current, pattern=".*", class="warning", info=NA_character_,...){ messages <- list() warnings <- list() errors <- list() tryCatch(withCallingHandlers(current , warning = function(w){ warnings <<- append(warnings, list(w)) invokeRestart("muffleWarning") } , message = function(m) { messages <<- append(messages, list(m)) invokeRestart("muffleMessage") } ) , error = function(e) errors <<- append(errors, list(e)) ) nmsg <- length(messages) nwrn <- length(warnings) nerr <- length(errors) results <- sapply(warnings, function(w) { inherits(w, class) && grepl(pattern, w$message, ...) }) if (any(results)){ result <- TRUE short <- diff <- NA_character_ } else { result <- FALSE short <- "xcpt" diff <- if ( nwrn == 0 ){ "No warning was emitted" } else { n_right_class <- sum(sapply(warnings, function(w) inherits(w, class))) if (n_right_class == 0){ head <- sprintf("Found %d warning(s), but not of class '%s'.", nwrn, class) head <- paste(head, "Showing up to three warnings:\n") body <- first_n(warnings) paste(head, body) } else { wrns <- Filter(function(w) inherits(w,class), warnings) head <- sprintf("Found %d warnings(s) of class '%s', but not matching '%s'." , nwrn, class, pattern) head <- paste(head,"\nShowing up to three warnings:\n") body <- first_n(wrns) paste(head, body) } } } if (!result && (nmsg > 0 || nerr > 0)) diff <- paste0(diff,sprintf("\nAlso found %d message(s) and %d error(s)" , nmsg, nerr)) tinytest(result, call=sys.call(sys.parent(1)) , short=short, diff=diff, info=info) } expect_message <- function(current, pattern=".*", class="message", info=NA_character_, ...){ messages <- list() warnings <- list() errors <- list() tryCatch(withCallingHandlers(current , warning = function(w){ warnings <<- append(warnings, list(w)) invokeRestart("muffleWarning") } , message = function(m) { messages <<- append(messages, list(m)) invokeRestart("muffleMessage") } ) , error = function(e) errors <<- append(errors, list(e)) ) nmsg <- length(messages) nwrn <- length(warnings) nerr <- length(errors) results <- sapply(messages, function(m) { inherits(m, class) && grepl(pattern, m$message, ...) }) if (any(results)){ result <- TRUE short <- diff <- NA_character_ } else { result <- FALSE short <- "xcpt" diff <- if (length(messages) == 0){ "No message was emitted" } else { n_right_class <- sum(sapply(messages, function(m) inherits(m, class))) if (n_right_class == 0){ head <- sprintf("Found %d message(s), but not of class '%s'.", nmsg, class) head <- paste(head, "Showing up to three messages:\n") body <- first_n(messages) paste(head, body) } else { msgs <- Filter(function(m) inherits(m,class), messages) head <- sprintf("Found %d message(s) of class '%s', but not matching '%s'." , nmsg, class, pattern) head <- paste(head,"\nShowing up to three messages:\n") body <- first_n(msgs) paste(head, body) } } } if (!result && (nwrn > 0 || nerr > 0)) diff <- paste0(diff,sprintf("\nAlso found %d warning(s) and %d error(s)" , nwrn, nerr)) tinytest(result, call=sys.call(sys.parent(1)) , short=short, diff=diff, info=info) } expect_stdout <- function(current, pattern=".*", info=NA_character_, ...){ value <- "" msg <- NA_character_ tc <- textConnection("value", open="w", local=TRUE) sink(file=tc, type="output", split=FALSE) tryCatch(current , error=function(e){sink(file=NULL, type="output"); stop(e)} ) sink(file = NULL, type="output") close(tc) value <- paste(value, collapse="\n") result <- grepl(pattern, value, ...) if (!result) msg <- sprintf("output '%s'\n does not match pattern '%s'", value, pattern) tinytest(result, call = sys.call(sys.parent(1)) , short= if(result) NA_character_ else "xcpt" , diff = msg , info = info) } expect_equal_to_reference <- function(current, file, ...){ eetr(current=current, file=file, type="equal", ...) } expect_equivalent_to_reference <- function(current, file, ...){ eetr(current=current, file=file, type="equivalent", ...) } eetr <- function (current, file, type=c("equal","equivalent"), ...){ if (file.exists(file)){ out <- if (type=="equal") tinytest::expect_equal(current, readRDS(file), ...) else tinytest::expect_equivalent(current, readRDS(file), ...) if (!out){ diff <- attr(out, "diff") diff <- paste( sprintf("current does not match target read from %s\n", file) , diff) attr(out,"diff") <- diff } out } else { tinytest::expect_null(saveRDS(current, file) , info=sprintf("Stored value in %s", file)) } } report_side_effects <- function(report=TRUE, envvar=report, pwd=report, files=report, locale=report){ stopifnot(is.logical(envvar)) list(envvar=envvar, pwd=pwd, files=files, locale=locale) } capture_se <- function(fun, env){ function(...){ out <- fun(...) env$sidefx <- out if (out[['envvar']]) env$envvar <- Sys.getenv() if (out[['pwd']]) env$pwd <- getwd() if (out[['files']]){ env$filesdir <- getwd() env$files <- file.info(dir(env$filesdir, recursive=TRUE, full.names=TRUE)) } if (out[['locale']]){ env$locale <- Sys.getlocale() } out } } report_envvar <- function(env){ if ( !isTRUE(env$sidefx[['envvar']]) ) return(NULL) old <- env$envvar current <- Sys.getenv() if (identical(old, current)) return(NULL) out <- dlist_diff(env$envvar, current,"envvar") env$envvar <- current out } locale_vector <- function(x){ x <- strsplit(x,";")[[1]] values <- sub("^.*=","",x) names(values) <- sub("=.*","",x) values <- values[order(names(values))] values } report_locale <- function(env){ if ( !isTRUE(env$sidefx[['locale']]) ) return(NULL) current <- Sys.getlocale() if (identical(env$locale, current)) return(NULL) out <- character(0) cur <- locale_vector(current) old <- locale_vector(env$locale) i <- cur != old cur <- cur[i] old <- old[i] diff <- sprintf("%s changed from '%s' to '%s'", names(cur), old, cur) diff <- paste(diff, collapse="\n") env$locale <- current tinytest(NA , call = sys.call(sys.parent(1)) , diff = diff , short = "lcle" , info = "Locale setting changed" ) } dlist_diff <- function(old, new, type){ if (identical(old,new)) return() old.vars <- names(old) new.vars <- names(new) removed <- setdiff(old.vars, new.vars) added <- setdiff(new.vars, old.vars) survived <- intersect(old.vars, new.vars) changed <- survived[ old[survived] != new[survived] ] rem <- if (length(removed) == 0 ) NULL else sprintf("Removed %s '%s' with value '%s'", type, removed, old[removed]) if(!is.null(rem)) rem <- paste(rem, collapse="\n") add <- if (length(added) == 0) NULL else sprintf("Added %s '%s' with value '%s'", type, added, new[added]) if (!is.null(add)) add <- paste(add, collapse="\n") cng <- if ( length(changed) == 0 ) NULL else sprintf("Changed %s '%s' from '%s' to '%s'" , type, changed, old[changed], new[changed]) if (!is.null(cng)) cng <- paste(cng, collapse="\n") long <- paste(c(rem, add, cng),collapse="\n") if (long == "") return() tinytest(NA , call = sys.call(sys.parent(1)) , diff = long , short = "envv" ) } report_cwd <- function(env){ if ( !isTRUE(env$sidefx[['pwd']]) ) return(NULL) old <- env$pwd current <- getwd() if ( identical(old, current) ) return(NULL) msg <- sprintf("Working directory changed from \n '%s'\nto\n '%s'", old, current) out <- tinytest(NA , call = sys.call(sys.parent(1)) , short = "wdir" , diff = msg ) env$pwd <- current out } report_files <- function(env){ if (!isTRUE(env$sidefx[['files']])) return(NULL) old <- env$files new <- file.info(dir(env$filesdir, recursive=TRUE, full.names=TRUE)) if ( identical(old, new) ) return(NULL) on.exit(env$files <- new) oldfiles <- rownames(old) newfiles <- rownames(new) created <- setdiff(newfiles, oldfiles) removed <- setdiff(oldfiles, newfiles) remain <- intersect(oldfiles, newfiles) touched <- remain[old[remain,'mtime'] != new[remain, 'mtime']] cre <- sprintf("Created: %s", if (length(created)>0) paste(created, collapse=", ") else character(0)) rem <- sprintf("Removed: %s", if (length(removed)>0) paste(removed, collapse=", ") else character(0)) alt <- sprintf("Touched: %s", if (length(touched)>0) paste(touched, collapse=", ") else character(0)) diff <- paste(c(cre, rem, alt), collapse="\n") if (nchar(diff) == 0) return(NULL) tinytest(NA , call = sys.call(sys.parent(1)) , diff = diff , short = "file" , info = "CRAN policy forbids writing in the package installation folder." ) }
plrls = function(x, y, h = 0, k1 = 1, k2 = 1, epsilon = 1e-5){ if(h < 0 | h > 1) stop("h must be a value between 0 and 1.") n <- ncol(x) m <- nrow(x) X <- x y <- as.matrix(y) vars <- colnames(x) j <- matrix(1, ncol = 1, nrow = m) X.abs <- abs(X) f1 <- -2 * k1 * t(X) %*% y f2 <- k2 * (1-h) * t(X.abs) %*% j f <- rbind(f1, f2, f2) H0 <- matrix(0, nrow = n, ncol = n) H1 <- t(X) %*% X H2 <- diag(n) * epsilon H <- cbind(k1 * H1, H0, H0) H <- rbind(H, cbind(H0, H2, H0)) H <- rbind(H, cbind(H0, H0, H2)) H <- 2 * H X.pos <- X * (X >= 0) X.neg <- X * (X < 0) L1 <- cbind(X, -(1-h) * X.neg, (1-h) * X.pos) L2 <- cbind(X, -(1-h) * X.pos, (1-h) * X.neg) L3 <- cbind(H0, H2, H0) L4 <- cbind(H0, H0, H2) L <- rbind(-L1, L2, -L3, -L4) r <- rbind(-y, y, matrix(0, ncol = 1, nrow = 2*n)) p <- quadprog::solve.QP(Dmat = H, dvec = -f, Amat = -t(L), bvec = -r) coefs <- matrix(p$solution, nrow = n, byrow = FALSE, dimnames = list(vars, c("center", "left.spread", "right.spread"))) lims <- t(apply(X, 2, range)) rownames(lims) <- vars colnames(lims) <- c("min", "max") fuzzy <- list(call = NULL, x = x, y = y, lims = lims, method = "PLRLS", fuzzynum = "non-symmetric triangular", coef = coefs) class(fuzzy) <- "fuzzylm" fuzzy }
priorSampUni <- function(p, estimates, n.samp = 2e3){ if ("alpha" %in% estimates || "lambda2" %in% estimates || "lambda4" %in% estimates || "lambda6" %in% estimates || "glb" %in% estimates){ v0 <- p k0 <- 1e-10 t <- diag(p) T0 <- solve(t / k0) m <- array(0, c(n.samp, p, p)) for (i in 1:n.samp){ m[i, , ] <- LaplacesDemon::rinvwishart(v0, T0) } } out <- list() if ("alpha" %in% estimates) { priora <- apply(m, MARGIN = 1, applyalpha) out$prioralpha <- quantiles(priora[priora >= 0]) } if ("lambda2" %in% estimates) { priorlambda2 <- apply(m, MARGIN = 1, applylambda2) out$priorlambda2 <- quantiles(priorlambda2[priorlambda2 >= 0]) } if ("lambda4" %in% estimates) { priorlambda4 <- apply(m, MARGIN = 1, applylambda4NoCpp) out$priorlambda4 <- quantiles(priorlambda4[priorlambda4 >= 0]) } if ("lambda6" %in% estimates) { priorlambda6 <- apply(m, MARGIN = 1, applylambda6) out$priorlambda6 <- quantiles(priorlambda6[priorlambda6 >= 0]) } if ("glb" %in% estimates) { priorglb <- glbOnArrayCustom(m) out$priorglb <- quantiles(priorglb[priorglb >= 0]) } if ("omega" %in% estimates) { H0 <- 1 l0k <- rep(0, p) a0k <- 1 b0k <- 2 prioromega <- numeric(n.samp) for (i in 1:n.samp) { invpsi <- rgamma(p, a0k, b0k) psi <- 1 / invpsi lambda <- rnorm(p, l0k, sqrt(psi * H0)) prioromega[i] <- omegaBasic(lambda, psi) } out$prioromega <- quantiles(prioromega[prioromega >= 0]) } return(out) } omegasPrior <- function(k, ns, nsamp = 2e3) { idex <- matrix(seq(1:k), ns, k / ns, byrow = TRUE) imat <- matrix(FALSE, k, ns) for (i in 1:ns) { imat[idex[i, ], i] <- TRUE } H0k <- rep(1, ns) l0k <- matrix(0, k, ns) a0k <- 2 b0k <- 1 H0kw <- 2.5 beta0k <- numeric(ns) a0kw <- 2 b0kw <- 1 R0w <- diag(rep(1 / (k), ns + 1)) p0w <- ns^2 pars <- list(H0k = H0k, a0k = a0k, b0k = b0k, l0k = l0k, H0kw = H0kw, a0kw = a0kw, b0kw = b0kw, beta0k = beta0k, R0w = R0w, p0w = p0w) omh_prior <- numeric(nsamp) omt_prior <- numeric(nsamp) for (i in 1:nsamp) { invpsi <- rgamma(k, pars$a0k, pars$b0k) psi <- 1 / invpsi lambda <- rnorm(k, pars$l0k[imat], sqrt(psi * rep(pars$H0k, each = k / ns))) invpsiw <- rgamma(ns, pars$a0kw, pars$b0kw) psiw <- 1 / invpsiw beta <- rnorm(ns, pars$beta0k, sqrt(psiw*pars$H0kw)) lmat <- pars$l0k lmat[imat] <- lambda lmat <- cbind(0, lmat) bmat <- matrix(0, ns + 1, ns + 1) bmat[2:(ns + 1), 1] <- beta om_prior <- omegasSeco(lmat, bmat, diag(psi), diag(c(1, psiw))) omh_prior[i] <- om_prior[1] omt_prior[i] <- om_prior[2] } return(list(omh_prior = omh_prior, omt_prior = omt_prior)) }
get_predictions_polr <- function(model, fitfram, ci.lvl, linv, value_adjustment, terms, model_class, vcov.fun, vcov.type, vcov.args, condition, interval, ...) { se <- (!is.null(ci.lvl) && !is.na(ci.lvl)) || !is.null(vcov.fun) if (!is.null(ci.lvl) && !is.na(ci.lvl)) ci <- (1 + ci.lvl) / 2 else ci <- .975 prdat <- stats::predict( model, newdata = fitfram, type = "probs", ... ) prdat <- as.data.frame(prdat) if (nrow(prdat) > nrow(fitfram) && ncol(prdat) == 1) { colnames(prdat)[1] <- "predicted" return(.rownames_as_column(prdat, var = "response.level")) } fitfram <- cbind(prdat, fitfram) fitfram <- .gather(fitfram, names_to = "response.level", values_to = "predicted", colnames(prdat)) se.pred <- .standard_error_predictions( model = model, prediction_data = fitfram, value_adjustment = value_adjustment, terms = terms, model_class = model_class, vcov.fun = vcov.fun, vcov.type = vcov.type, vcov.args = vcov.args, condition = condition, interval = interval ) if (.check_returned_se(se.pred) && isTRUE(se)) { se.fit <- se.pred$se.fit fitfram <- se.pred$prediction_data fitfram$conf.low <- linv(stats::qlogis(fitfram$predicted) - stats::qnorm(ci) * se.fit) fitfram$conf.high <- linv(stats::qlogis(fitfram$predicted) + stats::qnorm(ci) * se.fit) attr(fitfram, "std.error") <- se.fit attr(fitfram, "prediction.interval") <- attr(se.pred, "prediction_interval") } else { fitfram$conf.low <- NA fitfram$conf.high <- NA } fitfram }
setGeneric("sim_resp", function(ip, theta, prop_missing = 0, output = "matrix") {standardGeneric("sim_resp")}) setMethod( f = "sim_resp", signature = c(ip = "Item"), function(ip, theta, prop_missing = 0, output = "matrix") { if (ip$model %in% UNIDIM_DICHO_MODELS) { u <- runif(length(theta)) P <- prob(ip = ip, theta = theta)[, 2] return(stats::setNames(as.integer(u < P), names(theta))) } else if (ip$model %in% c("PCM", "GRM", "GPCM", "GPCM2")) { u <- runif(length(theta)) P <- prob(ip = ip, theta = theta) cP <- t(apply(P, MARGIN = 1, cumsum)) return(stats::setNames(apply(cP > u, 1, function(x) which(x)[1]) - 1L, names(theta))) } else stop("This model is not implemented in this 'sim_resp' function.") } ) setMethod( f = "sim_resp", signature = c(ip = "Testlet"), function(ip, theta, prop_missing = 0, output = "matrix"){ ip <- ip@item_list return(sim_resp(ip, theta, prop_missing = prop_missing, output = output)) } ) setMethod( f = "sim_resp", signature = c(ip = "Itempool"), function(ip, theta, prop_missing = 0, output = "matrix") { if (output == "matrix") { if (all(ip$model %in% c(UNIDIM_DICHO_MODELS, UNIDIM_POLY_MODELS, "BTM"))) { result <- sapply(ip@item_list, FUN = function(x) sim_resp(ip = x, theta = theta)) col_names <- ip$item_id if (!is.matrix(result)) { if (is.list(result)) { col_names <- ip$resp_id result <- unlist(result) } result <- matrix(result, nrow = length(theta)) } result[sample(1:length(result), round(length(result)*prop_missing))] <- NA if (is.null(names(theta))) { rownames(result) <- paste0("S", 1:length(theta)) } else rownames(result) <- names(theta) colnames(result) <- col_names return(result) } else stop("This model is not implemented in 'sim_resp' function.") } else if (output == "response_set") { return(sim_resp_response_set_cpp(theta = theta, ip = ip, prop_missing = prop_missing)) } else stop(paste0("Invalid 'output'. 'output' argument can only be either ", "\"matrix\" or \"response_set\"."), call. = FALSE) } ) setMethod( f = "sim_resp", signature = c(ip = "numMatDfListChar"), function(ip, theta, prop_missing = 0, output = "matrix"){ if (inherits(ip, "numeric")) { tryCatch({ return(sim_resp(ip = itempool(ip), theta = theta, prop_missing = prop_missing, output = output)) }, error = function(e) { stop("Cannot convert object to an 'Item' object. Please provide a ", "valid object using 'item()' function. \nThe reason for ", "conversion failure: ", e) }) } else if (inherits(ip, c("matrix", "data.frame", "list"))) { tryCatch({ return(sim_resp(ip = itempool(ip), theta = theta, prop_missing = prop_missing, output = output)) }, error = function(e) { stop("Cannot convert object to an 'Itempool' object. Please ", "provide a valid object using 'itempool()' function. \nThe ", "reason for conversion failure: \n", e) }) } else stop("Cannot convert object to an 'Item' or an 'Itempool' object. ", "Please provide a valid 'Item' or 'Itempool' object using either ", "'item()' or 'itempool()' function.") } )
library(shiny) library(shinyBS) shinyApp( ui = fluidPage( tabsetPanel( tabPanel("Tab plotOutput("genericPlot") ), tabPanel("Tab checkboxInput("showOptions", "Show Options"), uiOutput("ui_multiview_customize"), plotOutput("multiview_plot") ) ) ), server = function(input, output, session) { output$genericPlot <- renderPlot(plot(rnorm(1000))) output$multiview_plot <- renderPlot(plot(runif(1000))) output$ui_multiview_customize <- renderUI({ if(input$showOptions) { bsCollapse( bsCollapsePanel(title = "View Options", checkboxInput("multiview_checkbox", label = "Include warmup", value = FALSE), hr(), tipify(downloadButton("download_multiview", "Save as ggplot2 objects"), title = "Save ggplot2 object in .RData file.", placement="right") ) ) } }) } )
library(FMM) test_that("Parameter values in correct range.",{ mouseGeneExpFit <- fitFMM(mouseGeneExp, nback = 2) expect_gte(mouseGeneExpFit@A[1], 0) expect_gte(mouseGeneExpFit@A[2], 0) expect_gte(mouseGeneExpFit@alpha[1], 0) expect_gte(mouseGeneExpFit@alpha[2], 0) expect_gte(mouseGeneExpFit@omega[1], 0) expect_gte(mouseGeneExpFit@omega[2], 0) expect_gte(mouseGeneExpFit@beta[1], 0) expect_gte(mouseGeneExpFit@beta[2], 0) expect_lte(mouseGeneExpFit@alpha[1], 2*pi) expect_lte(mouseGeneExpFit@alpha[2], 2*pi) expect_lte(mouseGeneExpFit@omega[1], 2*pi) expect_lte(mouseGeneExpFit@omega[2], 2*pi) expect_lte(mouseGeneExpFit@beta[1], 2*pi) expect_lte(mouseGeneExpFit@beta[2], 2*pi) }) test_that("Returns an S4 class object (FMM object).",{ expect_s4_class(fitFMM(mouseGeneExp, nback = 2), "FMM") expect_s4_class(fitFMM(neuronalAPTrain, nback = 6), "FMM") expect_s4_class(fitFMM(neuronalSpike, nback = 2), "FMM") }) test_that("Correct length of each vector slot.",{ mouseGeneExpFit <- fitFMM(mouseGeneExp, nback = 2) neuronalAPTrainFit <- fitFMM(neuronalAPTrain, nback = 6) neuronalSpikeFit <- fitFMM(neuronalSpike, nback = 2) expect_length(mouseGeneExpFit@A, 2) expect_length(mouseGeneExpFit@alpha, 2) expect_length(mouseGeneExpFit@beta, 2) expect_length(mouseGeneExpFit@omega, 2) expect_length(mouseGeneExpFit@M, 1) expect_length(mouseGeneExpFit@timePoints, length(mouseGeneExp)) expect_length(mouseGeneExpFit@fittedValues, length(mouseGeneExp)) expect_length(mouseGeneExpFit@data, length(mouseGeneExp)) expect_length(neuronalAPTrainFit@A, 6) expect_length(neuronalAPTrainFit@alpha, 6) expect_length(neuronalAPTrainFit@beta, 6) expect_length(neuronalAPTrainFit@omega, 6) expect_length(neuronalAPTrainFit@M, 1) expect_length(neuronalAPTrainFit@timePoints, length(neuronalAPTrain)) expect_length(neuronalAPTrainFit@fittedValues, length(neuronalAPTrain)) expect_length(neuronalAPTrainFit@data, length(neuronalAPTrain)) expect_length(neuronalSpikeFit@A, 2) expect_length(neuronalSpikeFit@alpha, 2) expect_length(neuronalSpikeFit@beta, 2) expect_length(neuronalSpikeFit@omega, 2) expect_length(neuronalSpikeFit@M, 1) expect_length(neuronalSpikeFit@timePoints, length(neuronalSpike)) expect_length(neuronalSpikeFit@fittedValues, length(neuronalSpike)) expect_length(neuronalSpikeFit@data, length(neuronalSpike)) }) test_that("FMM fit in limit parameter values simulated data.",{ tmpData <- generateFMM(0, A = c(1, 1), alpha = c(0, pi), beta = c(pi/2, 3*pi/2), omega = c(0.05, 0.05), length.out = 50, plot = F)$y tmpDataFit <- fitFMM(tmpData, nback = 2) expect_gte(tmpDataFit@A[1], 0) expect_gte(tmpDataFit@A[2], 0) expect_gte(tmpDataFit@alpha[1], 0) expect_gte(tmpDataFit@alpha[2], 0) expect_gte(tmpDataFit@omega[1], 0) expect_gte(tmpDataFit@omega[2], 0) expect_gte(tmpDataFit@beta[1], 0) expect_gte(tmpDataFit@beta[2], 0) expect_lte(tmpDataFit@alpha[1], 2*pi) expect_lte(tmpDataFit@alpha[2], 2*pi) expect_lte(tmpDataFit@omega[1], 2*pi) expect_lte(tmpDataFit@omega[2], 2*pi) expect_lte(tmpDataFit@beta[1], 2*pi) expect_lte(tmpDataFit@beta[2], 2*pi) expect_length(tmpDataFit@M, 1) expect_length(tmpDataFit@A, 2) expect_length(tmpDataFit@alpha, 2) expect_length(tmpDataFit@beta, 2) expect_length(tmpDataFit@omega, 2) expect_length(tmpDataFit@timePoints, length(tmpData)) expect_length(tmpDataFit@fittedValues, length(tmpData)) expect_length(tmpDataFit@data, length(tmpData)) expect_s4_class(tmpDataFit, "FMM") tmpData2 <- generateFMM(0, A = c(1, 1), alpha = c(0, pi), beta = c(0,pi), omega = c(0.95, 0.05), length.out = 50, plot = F)$y tmpDataFit2 <- fitFMM(tmpData2, nback = 2) expect_gte(tmpDataFit2@A[1], 0) expect_gte(tmpDataFit2@A[2], 0) expect_gte(tmpDataFit2@alpha[1], 0) expect_gte(tmpDataFit2@alpha[2], 0) expect_gte(tmpDataFit2@omega[1], 0) expect_gte(tmpDataFit2@omega[2], 0) expect_gte(tmpDataFit2@beta[1], 0) expect_gte(tmpDataFit2@beta[2], 0) expect_lte(tmpDataFit2@alpha[1], 2*pi) expect_lte(tmpDataFit2@alpha[2], 2*pi) expect_lte(tmpDataFit2@omega[1], 2*pi) expect_lte(tmpDataFit2@omega[2], 2*pi) expect_lte(tmpDataFit2@beta[1], 2*pi) expect_lte(tmpDataFit2@beta[2], 2*pi) expect_length(tmpDataFit2@M, 1) expect_length(tmpDataFit2@A, 2) expect_length(tmpDataFit2@alpha, 2) expect_length(tmpDataFit2@beta, 2) expect_length(tmpDataFit2@omega, 2) expect_length(tmpDataFit2@timePoints, length(tmpData2)) expect_length(tmpDataFit2@fittedValues, length(tmpData2)) expect_length(tmpDataFit2@data, length(tmpData2)) expect_s4_class(tmpDataFit2, "FMM") })
estimate_truncation <- function(obs, max_truncation = 10, model = NULL, CrIs = c(0.2, 0.5, 0.9), verbose = TRUE, ...) { dirty_obs <- purrr::map(obs, data.table::as.data.table) nrow_obs <- order(purrr::map_dbl(dirty_obs, nrow)) dirty_obs <- dirty_obs[nrow_obs] obs <- purrr::map(dirty_obs, data.table::copy) obs <- purrr::map(1:length(obs), ~ obs[[.]][, (as.character(.)) := confirm][, confirm := NULL]) obs <- purrr::reduce(obs, merge, all = TRUE) obs_start <- nrow(obs) - max_truncation - sum(is.na(obs$`1`)) + 1 obs_dist <- purrr::map_dbl(2:(ncol(obs)), ~ sum(is.na(obs[[.]]))) obs_data <- obs[, -1][, purrr::map(.SD, ~ ifelse(is.na(.), 0, .))] obs_data <- obs_data[obs_start:.N] data <- list( obs = obs_data, obs_dist = obs_dist, t = nrow(obs_data), obs_sets = ncol(obs_data), trunc_max = array(max_truncation) ) init_fn <- function() { data <- list( logmean = array(rnorm(1, 0, 1)), logsd = array(abs(rnorm(1, 0, 1))) ) return(data) } if (is.null(model)) { model <- stanmodels$estimate_truncation } fit <- rstan::sampling(model, data = data, init = init_fn, refresh = ifelse(verbose, 50, 0), ...) out <- list() out$dist <- list( mean = round(rstan::summary(fit, pars = "logmean")$summary[1], 3), mean_sd = round(rstan::summary(fit, pars = "logmean")$summary[3], 3), sd = round(rstan::summary(fit, pars = "logsd")$summary[1], 3), sd_sd = round(rstan::summary(fit, pars = "logsd")$summary[3], 3), max = max_truncation ) recon_obs <- extract_stan_param(fit, "recon_obs", CrIs = CrIs, var_names = TRUE) recon_obs <- recon_obs[, id := variable][, variable := NULL] recon_obs <- recon_obs[, dataset := 1:.N][, dataset := dataset %% data$obs_sets][ dataset == 0, dataset := data$obs_sets] last_obs <- data.table::copy(dirty_obs[[length(dirty_obs)]])[, last_confirm := confirm][, confirm := NULL] link_obs <- function(index) { target_obs <- dirty_obs[[index]][, index := .N - 0:(.N-1)] target_obs <- target_obs[index < max_truncation] estimates <- recon_obs[dataset == index][, c("id", "dataset") := NULL] estimates <- estimates[, lapply(.SD, as.integer)] estimates <- estimates[, index := .N - 0:(.N-1)] estimates[, c("n_eff", "Rhat") := NULL] target_obs <- data.table::merge.data.table( target_obs, last_obs, by = "date") target_obs[,report_date := max(date)] target_obs <- data.table::merge.data.table(target_obs, estimates, by = "index", all.x = TRUE) target_obs <- target_obs[order(date)][, index := NULL] return(target_obs) } out$obs <- purrr::map(1:(data$obs_sets), link_obs) out$obs <- data.table::rbindlist(out$obs) out$last_obs <- last_obs out$cmf <- extract_stan_param(fit, "cmf", CrIs = CrIs) out$cmf <- data.table::as.data.table(out$cmf)[, index := .N:1] data.table::setcolorder(out$cmf, "index") out$data <- data out$fit <- fit class(out) <- c("estimate_truncation", class(out)) return(out) } plot.estimate_truncation <- function(x, ...) { plot <- ggplot2::ggplot(x$obs, ggplot2::aes(x = date, y = last_confirm)) + ggplot2::geom_col(fill = "grey", col = "white", show.legend = FALSE, na.rm = TRUE) + ggplot2::geom_point(data = x$obs, ggplot2::aes(x = date, y = confirm)) + ggplot2::facet_wrap(~report_date, scales = "free") plot <- plot_CrIs(plot, extract_CrIs(x$obs), alpha = 0.8, size = 1) plot <- plot + cowplot::theme_cowplot() + ggplot2::labs(y = "Confirmed Cases", x = "Date", col = "Type", fill = "Type") + ggplot2::scale_x_date(date_breaks = "day", date_labels = "%b %d") + ggplot2::scale_y_continuous(labels = scales::comma) + ggplot2::theme(axis.text.x = ggplot2::element_text(angle = 90)) return(plot) }
URY <- function(level){ x <- NULL if(level==1){ x1 <- github.cssegisanddata.covid19(country = "Uruguay") x2 <- ourworldindata.org(id = "URY") x <- full_join(x1, x2, by = "date") } return(x) }
simulatedData <- function(p = 50, n = 100, mu = 100, sigma = 0.25, ppower = 1, noise = F, seed = NULL){ if(!is.null(seed)) set.seed(seed) g <- barabasi.game(p, power = ppower, directed = F) A <- as.matrix(get.adjacency(g, type = "both", names = T)) diag(A) <- 1 rownames(A) <- colnames(A) <- paste("gene", 1:p, sep = "_") nDistToCreate <- sum(A[upper.tri(A, diag = T)]) muN <- rpois(nDistToCreate, mu) if(sigma == 0){ poissGen <- t(sapply(muN, function(x) rpois(n, x))) } else { rlognormpois <- function(n, lambda, sigma){ eps <- rnorm(n) x <- rpois(n, exp(log(lambda) + sigma*eps)) return(x) } nLognormpois <- ceiling(nDistToCreate * sample(seq(.10, .50, by = .1), size = 1)) idx <- sample(1:nDistToCreate, size = nLognormpois) poissGen <- matrix(0, nrow = nDistToCreate, ncol = n) poissGen[-idx, ] <- t(sapply(muN[-idx], function(x) rpois(n, x))) poissGen[idx, ] <- t(sapply(muN[idx], function(x) rlognormpois(n, lambda = x, sigma = sigma))) } rowNames <- NULL for(i in 1:nrow(A)){ tmp <- A[i, i:ncol(A), drop = F] rowNames <- c(rowNames, paste("G", i, "-", sub("gene_", "G", colnames(tmp[, which(tmp == 1), drop = F])), sep = "")) } rownames(poissGen) <- rowNames X <- matrix(0, p, n) rownames(X) <- rownames(A) colnames(X) <- paste("sample", 1:n, sep = "_") for(i in 1:p){ tmp <- strsplit(rownames(poissGen), "-") tmp <- sapply(tmp, function(x) grep(paste("G", i, "$", sep = ""), x)) tmp <- which(sapply(tmp, length) != 0) X[i, ] <- colSums(poissGen[tmp, , drop = F]) if(noise == T){ rrange <- max(X[i, ]) - min(X[i, ]) X[i, ] <- X[i, ] + round(0.1 * (-1)^sample(0:1, size = n, replace = T) * sample(1:rrange, size = n, replace = T)) X[i, X[i, ] <= 0] <- 0 } } ans <- list(graph = g, adjMat = A, counts = X) return(ans) }
mle_gamma_lnorm <- function(x, gamma_mean1 = FALSE, lnorm_mean1 = TRUE, integrate_tol = 1e-8, estimate_var = FALSE, ...) { if (! gamma_mean1 & ! lnorm_mean1) { stop("For identifiability, either 'gamma_mean1' or 'lnorm_mean1' (or both) has to be TRUE.") } n <- length(x) lf <- function(x, g, alpha, beta, mu, sigsq) { g <- matrix(g, nrow = 1) f_xg <- apply(g, 2, function(z) { s <- z / (1 - z) dlnorm(x, meanlog = log(s) + mu, sdlog = sqrt(sigsq)) * dgamma(s, shape = alpha, scale = beta) }) out <- matrix(f_xg / (1 - g)^2, ncol = ncol(g)) } extra.args <- list(...) if (gamma_mean1 & ! lnorm_mean1) { theta.labels <- c("beta", "mu", "sigsq") extra.args <- list_override( list1 = list(start = c(1, 0, 1), lower = c(0, -Inf, 0), control = list(rel.tol = 1e-6, eval.max = 1000, iter.max = 750)), list2 = extra.args ) } else if (! gamma_mean1 & lnorm_mean1) { theta.labels <- c("alpha", "beta", "sigsq") extra.args <- list_override( list1 = list(start = c(1, 1, 1), lower = c(0, 0, 0), control = list(rel.tol = 1e-6, eval.max = 1000, iter.max = 750)), list2 = extra.args ) } else if (gamma_mean1 & lnorm_mean1) { theta.labels <- c("beta", "sigsq") extra.args <- list_override( list1 = list(start = c(1, 1), lower = c(0, 0), control = list(rel.tol = 1e-6, eval.max = 1000, iter.max = 750)), list2 = extra.args ) } llf <- function(f.theta) { if (gamma_mean1 & ! lnorm_mean1) { f.beta <- f.theta[1] f.mu <- f.theta[2] f.sigsq <- f.theta[3] f.alpha <- 1 / f.beta } else if (! gamma_mean1 & lnorm_mean1) { f.alpha <- f.theta[1] f.beta <- f.theta[2] f.sigsq <- f.theta[3] f.mu <- -1/2 * f.sigsq } else if (gamma_mean1 & lnorm_mean1) { f.beta <- f.theta[1] f.sigsq <- f.theta[2] f.alpha <- 1 / f.beta f.mu <- -1/2 * f.sigsq } int.vals <- c() for (ii in 1: n) { int.ii <- cubature::hcubature(f = lf, tol = integrate_tol, lowerLimit = 0, upperLimit = 1, vectorInterface = TRUE, x = x[ii], alpha = f.alpha, beta = f.beta, mu = f.mu, sigsq = f.sigsq) int.vals[ii] <- int.ii$integral if (int.ii$integral == 0) { print(paste("Integral is 0 for ii = ", ii, sep = "")) print(f.theta) skip.rest <- TRUE break } } return(-sum(log(int.vals))) } ml.max <- do.call(nlminb, c(list(objective = llf), extra.args)) theta.hat <- ml.max$par names(theta.hat) <- theta.labels ret.list <- list(theta.hat = theta.hat) if (estimate_var) { hessian.mat <- pracma::hessian(f = llf, x0 = theta.hat) theta.variance <- try(solve(hessian.mat), silent = TRUE) if (class(theta.variance) == "try-error" || ! all(eigen(x = theta.variance, only.values = TRUE)$values > 0)) { message("Estimated Hessian matrix is singular, so variance-covariance matrix cannot be obtained.") ret.list$theta.var <- NULL } else { colnames(theta.variance) <- rownames(theta.variance) <- theta.labels ret.list$theta.var <- theta.variance } } ret.list$nlminb.object <- ml.max ret.list$aic <- 2 * (length(theta.hat) + ml.max$objective) return(ret.list) }
vcov.mtvgarch <- function (object, spec = c("sigma2", "tv", "garch", "cc"), ...) { spec <- match.arg(spec) if (spec != "cc") { results <- list() m <- ncol(object$y) for (i in 1:m) { name <- object$names.y[i] object.i <- object$Objs[[paste("obj", i, sep = "")]] if (is.null(object$order.g) || any(object$order.g == 0)) { if (spec == "tv" || spec == "garch") { stop ("Only GARCH models have been estimated.") } } if (is.null(object$order.g) || object$order.g[i,1] == 0) { spec.i <- "sigma2" } if (!is.null(object$order.g) && object$order.g[i,1] != 0) { spec.i <- spec } results[[paste("vcov", paste(spec.i), name, sep = "_")]] <- vcov.tvgarch(object = object.i, spec = spec.i) } } if (spec == "cc") { if (object$turbo == TRUE) { jac.dcc <- jacobian(func = dccObj, x = object$par.dcc, z = object$residuals, sigma2 = object$sigma2, flag = 0) J.dcc <- crossprod(jac.dcc) H.dcc <- optimHess(par = object$par.dcc, fn = dccObj, z = object$residuals, sigma2 = object$sigma2, flag = 1) solHdcc <- solve(-H.dcc) object$vcov.dcc <- solHdcc %*% J.dcc %*% solHdcc } results <- object$vcov.dcc } return(results) }
<% more_alias_str <- '' if (exists('morealiases')) { morealiases <- strsplit(morealiases, ' ')[[1]] more_alias_str <- c(outer(morealiases, c('', '<-'), paste0)) more_alias_str <- c(more_alias_str, sprintf('set_%s', morealiases), sprintf('map_%s', morealiases)) more_alias_str <- paste(more_alias_str, collapse = ' ') } default_property <- huxtable::get_default_properties(attr_name)[[1]] if (is.list(default_property)) { default_property <- default_property[[1]] } if (typeof(default_property) == "character") { default_property <- sprintf("\"%s\"", default_property) } default_str <- if (exists("default")) paste("=", default) else "" %>
apply_pop_density <- function(pop, mastergrid_filename, output_dir, cores=NULL, rfg.countries.tag, quant = TRUE, blocks=NULL, verbose=TRUE, log=FALSE) { silent <- if (verbose) FALSE else TRUE rfg.rst.pop.census.tif <- file.path(output_dir, paste0("pop_census_mask_",rfg.countries.tag, ".tif")) rfg.rst.zonal.stats.rf.pred.tif<- file.path(output_dir, paste0("predict_density_rf_pred_",rfg.countries.tag, "_ZS_sum.tif")) rfg.predict.density.rf.pred <- file.path(output_dir, paste0("predict_density_rf_pred_", rfg.countries.tag, ".tif")) rst.predict.density.rf.pred <- raster(rfg.predict.density.rf.pred) df <- get_pop_census_all(pop) zonal_raster <- raster(mastergrid_filename) if (is.null(cores) | cores < 2 ){ v <- data.frame( raster::getValues(zonal_raster) ) colnames(v) <- c("v1") colnames(df) <- c("v1","v2") out <- plyr::join(v, df, type="left",by = "v1")[-1] out.rst.pop.census.raster <- zonal_raster raster::values(out.rst.pop.census.raster) <- out[[1]] rst.pop.census <- raster::writeRaster(out.rst.pop.census.raster, filename=rfg.rst.pop.census.tif, format="GTiff", datatype='FLT4S', overwrite=TRUE, options=c("COMPRESS=LZW"), NAflag=-99999) rm(out.rst.pop.census.raster) zonal.stats.rf.pred.sum <- zonal(rst.predict.density.rf.pred, zonal_raster, fun="sum") colnames(zonal.stats.rf.pred.sum) <- c("ADMINID", "sum") zonal.stats.rf.pred.sum <- zonal.stats.rf.pred.sum[sort.list(zonal.stats.rf.pred.sum[,1]), ] zonal.stats.rf.pred.sum <- as.data.frame(zonal.stats.rf.pred.sum[zonal.stats.rf.pred.sum[,1] != 0, ]) colnames(zonal.stats.rf.pred.sum) <- c("v1","v2") out.zonal.stats.rf.pred.sum <- plyr::join(v, zonal.stats.rf.pred.sum, type="left",by = "v1")[-1] out.zonal.stats.rf.pred.sum.raster <- zonal_raster raster::values(out.zonal.stats.rf.pred.sum.raster) <- out.zonal.stats.rf.pred.sum[[1]] rst.zonal.stats.rf.pred <- raster::writeRaster(out.zonal.stats.rf.pred.sum.raster, filename=rfg.rst.zonal.stats.rf.pred.tif, format="GTiff", datatype='FLT4S', overwrite=TRUE, options=c("COMPRESS=LZW"), NAflag=-99999) rm(out.zonal.stats.rf.pred.sum.raster) }else{ colnames(df) <- c("ADMINID", "ADMINPOP") log_info("MSG", paste0("Rasterizing input population data."), verbose=verbose, log=log) rst.pop.census <- rasterize_parallel(zonal_raster, df, cores=cores, blocks=blocks, NAflag=NULL, datatype=NULL, filename=rfg.rst.pop.census.tif, overwrite=TRUE, silent=silent) log_info("MSG", paste0("Computing zonal statistics of final RF prediction layer."), verbose=verbose, log=log) out.zonal.stats.rf.pred.sum <- calculate_zs_parallel(rst.predict.density.rf.pred, zonal_raster, fun="sum", cores=cores, blocks=blocks, silent=silent) colnames(out.zonal.stats.rf.pred.sum) <- c("ADMINID", "sum") out.zonal.stats.rf.pred.sum <- out.zonal.stats.rf.pred.sum[sort.list(out.zonal.stats.rf.pred.sum[,1]), ] out.zonal.stats.rf.pred.sum <- as.data.frame(out.zonal.stats.rf.pred.sum[out.zonal.stats.rf.pred.sum[,1] != 0, ]) log_info("MSG", paste0("Rasterizing the results of zonal statistics."), verbose=verbose, log=log) rst.zonal.stats.rf.pred <- rasterize_parallel(zonal_raster, out.zonal.stats.rf.pred.sum, cores=cores, blocks=blocks, NAflag=NULL, datatype=NULL, filename=rfg.rst.zonal.stats.rf.pred.tif, overwrite=TRUE, silent=silent) rm(out.zonal.stats.rf.pred.sum) } rfg.predict.density.rf.pred.final <- file.path(output_dir, paste0("ppp_",rfg.countries.tag, ".tif")) r_calc <- (rst.predict.density.rf.pred * rst.pop.census)/rst.zonal.stats.rf.pred writeRaster(r_calc, filename=rfg.predict.density.rf.pred.final, format="GTiff", overwrite=TRUE, NAflag=-99999, datatype='FLT4S', options=c("COMPRESS=LZW") ) return(r_calc) } apply_pop_density_constrained <- function(pop, mastergrid_filename, output_dir, cores=NULL, rfg.countries.tag, blocks=NULL, verbose=TRUE, log=FALSE) { silent <- if (verbose) FALSE else TRUE rfg.rst.pop.census.tif <- file.path(output_dir, paste0("pop_census_mask_",rfg.countries.tag, "_const.tif")) rfg.rst.zonal.stats.rf.pred.tif<- file.path(output_dir, paste0("predict_density_rf_pred_",rfg.countries.tag, "_ZS_sum_const.tif")) rfg.predict.density.rf.pred <- file.path(output_dir, paste0("predict_density_rf_pred_", rfg.countries.tag, "_const.tif")) rst.predict.density.rf.pred <- raster(rfg.predict.density.rf.pred) df <- get_pop_census_all(pop) zonal_raster <- raster(mastergrid_filename) if (is.null(cores) | cores < 2 ){ v <- data.frame( raster::getValues(zonal_raster) ) colnames(v) <- c("v1") colnames(df) <- c("v1","v2") out <- plyr::join(v, df, type="left",by = "v1")[-1] out.rst.pop.census.raster <- zonal_raster raster::values(out.rst.pop.census.raster) <- out[[1]] rst.pop.census <- raster::writeRaster(out.rst.pop.census.raster, filename=rfg.rst.pop.census.tif, format="GTiff", datatype='FLT4S', overwrite=TRUE, options=c("COMPRESS=LZW"), NAflag=-99999) rm(out.rst.pop.census.raster) zonal.stats.rf.pred.sum <- zonal(rst.predict.density.rf.pred, zonal_raster, fun="sum") colnames(zonal.stats.rf.pred.sum) <- c("ADMINID", "sum") zonal.stats.rf.pred.sum <- zonal.stats.rf.pred.sum[sort.list(zonal.stats.rf.pred.sum[,1]), ] zonal.stats.rf.pred.sum <- as.data.frame(zonal.stats.rf.pred.sum[zonal.stats.rf.pred.sum[,1] != 0, ]) colnames(zonal.stats.rf.pred.sum) <- c("v1","v2") out.zonal.stats.rf.pred.sum <- plyr::join(v, zonal.stats.rf.pred.sum, type="left",by = "v1")[-1] out.zonal.stats.rf.pred.sum.raster <- zonal_raster raster::values(out.zonal.stats.rf.pred.sum.raster) <- out.zonal.stats.rf.pred.sum[[1]] rst.zonal.stats.rf.pred <- raster::writeRaster(out.zonal.stats.rf.pred.sum.raster, filename=rfg.rst.zonal.stats.rf.pred.tif, format="GTiff", datatype='FLT4S', overwrite=TRUE, options=c("COMPRESS=LZW"), NAflag=-99999) rm(out.zonal.stats.rf.pred.sum.raster) }else{ colnames(df) <- c("ADMINID", "ADMINPOP") log_info("MSG", paste0("Rasterizing input population data using constarined mastegrid"), verbose=verbose, log=log) rst.pop.census <- rasterize_parallel(zonal_raster, df, cores=cores, blocks=blocks, NAflag=NULL, datatype=NULL, filename=rfg.rst.pop.census.tif, overwrite=TRUE, silent=silent) log_info("MSG", paste0("Computing zonal statistics of constarined final RF prediction layer."), verbose=verbose, log=log) out.zonal.stats.rf.pred.sum <- calculate_zs_parallel(rst.predict.density.rf.pred, zonal_raster, fun="sum", cores=cores, blocks=blocks, silent=silent) colnames(out.zonal.stats.rf.pred.sum) <- c("ADMINID", "sum") out.zonal.stats.rf.pred.sum <- out.zonal.stats.rf.pred.sum[sort.list(out.zonal.stats.rf.pred.sum[,1]), ] out.zonal.stats.rf.pred.sum <- as.data.frame(out.zonal.stats.rf.pred.sum[out.zonal.stats.rf.pred.sum[,1] != 0, ]) log_info("MSG", paste0("Rasterizing the results of zonal statistics."), verbose=verbose, log=log) rst.zonal.stats.rf.pred <- rasterize_parallel(zonal_raster, out.zonal.stats.rf.pred.sum, cores=cores, blocks=blocks, NAflag=NULL, datatype=NULL, filename=rfg.rst.zonal.stats.rf.pred.tif, overwrite=TRUE, silent=silent) rm(out.zonal.stats.rf.pred.sum) } rfg.predict.density.rf.pred.final <- file.path(output_dir, paste0("ppp_",rfg.countries.tag, "_const.tif")) r_calc <- (rst.predict.density.rf.pred * rst.pop.census)/rst.zonal.stats.rf.pred writeRaster(r_calc, filename=rfg.predict.density.rf.pred.final, format="GTiff", overwrite=TRUE, NAflag=-99999, datatype='FLT4S', options=c("COMPRESS=LZW") ) return(r_calc) }
testResiduals <- function(simulationOutput, plot = T){ opar = par(mfrow = c(1,3)) on.exit(par(opar)) out = list() out$uniformity = testUniformity(simulationOutput, plot = plot) out$dispersion = testDispersion(simulationOutput, plot = plot) out$outliers = testOutliers(simulationOutput, plot = plot) print(out) return(out) } testSimulatedResiduals <- function(simulationOutput){ message("testSimulatedResiduals is deprecated, switch your code to using the testResiduals function") testResiduals(simulationOutput) } testUniformity<- function(simulationOutput, alternative = c("two.sided", "less", "greater"), plot = T){ simulationOutput = ensureDHARMa(simulationOutput, convert = T) out <- suppressWarnings(ks.test(simulationOutput$scaledResiduals, 'punif', alternative = alternative)) if(plot == T) plotQQunif(simulationOutput = simulationOutput) return(out) } testBivariateUniformity<- function(simulationOutput, alternative = c("two.sided", "less", "greater"), plot = T){ simulationOutput = ensureDHARMa(simulationOutput, convert = T) out = NULL return(out) } testQuantiles <- function(simulationOutput, predictor = NULL, quantiles = c(0.25,0.5,0.75), plot = T){ if(plot == F){ out = list() out$data.name = deparse(substitute(simulationOutput)) simulationOutput = ensureDHARMa(simulationOutput, convert = T) res = simulationOutput$scaledResiduals pred = ensurePredictor(simulationOutput, predictor) dat=data.frame(res = simulationOutput$scaledResiduals , pred = pred) quantileFits <- list() pval = rep(NA, length(quantiles)) predictions = data.frame(pred = sort(dat$pred)) predictions = cbind(predictions, matrix(ncol = 2 * length(quantiles), nrow = nrow(dat))) for(i in 1:length(quantiles)){ datTemp = dat datTemp$res = datTemp$res - quantiles[i] dimSmooth = min(length(unique(datTemp$pred)), 10) quantResult = try(capture.output(quantileFits[[i]] <- qgam::qgam(res ~ s(pred, k = dimSmooth) , data =datTemp, qu = quantiles[i])), silent = T) if(inherits(quantResult, "try-error")){ message("Unable to calculate quantile regression for quantile ", quantiles[i], ". Possibly to few (unique) data points / predictions. Will be ommited in plots and significance calculations.") } else { x = summary(quantileFits[[i]]) pval[i] = min(p.adjust(c(x$p.table[1,4], x$s.table[1,4]), method = "BH")) quantPre = predict(quantileFits[[i]], newdata = predictions, se = T) predictions[, 2*i] = quantPre$fit + quantiles[i] predictions[, 2*i + 1] = quantPre$se.fit } } out$method = "Test for location of quantiles via qgam" out$alternative = "both" out$pvals = pval out$p.value = min(p.adjust(pval, method = "BH")) out$predictions = predictions out$qgamFits = quantileFits class(out) = "htest" } else if(plot == T) { out <- plotResiduals(simulationOutput = simulationOutput, form = predictor, quantiles = quantiles, quantreg = TRUE) } return(out) } testOutliers <- function(simulationOutput, alternative = c("two.sided", "greater", "less"), margin = c("both", "upper", "lower"), type = c("default","bootstrap", "binomial"), nBoot = 100, plot = T){ alternative = match.arg(alternative) margin = match.arg(margin) type = match.arg(type) data.name = deparse(substitute(simulationOutput)) simulationOutput = ensureDHARMa(simulationOutput, convert = "Model") if(type == "default"){ if(simulationOutput$integerResponse == FALSE) type = "binomial" else{ if(simulationOutput$nObs > 500) type = "binomial" else type = "bootstrap" } } if(type == "binomial"){ if(margin == "both") outliers = sum(simulationOutput$scaledResiduals < (1/(simulationOutput$nSim+1))) + sum(simulationOutput$scaledResiduals > (1-1/(simulationOutput$nSim+1))) if(margin == "upper") outliers = sum(simulationOutput$scaledResiduals > (1-1/(simulationOutput$nSim+1))) if(margin == "lower") outliers = sum(simulationOutput$scaledResiduals < (1/(simulationOutput$nSim+1))) outFreqH0 = 1/(simulationOutput$nSim +1) * ifelse(margin == "both", 2, 1) trials = simulationOutput$nObs out = binom.test(outliers, trials, p = outFreqH0, alternative = alternative) out$method = "DHARMa outlier test based on exact binomial test with approximate expectations" out$data.name = data.name out$margin = margin names(out$statistic) = paste("outliers at", margin, "margin(s)") names(out$parameter) = "observations" names(out$estimate) = paste("frequency of outliers (expected:", out$null.value,")") if (simulationOutput$integerResponse == T & out$p.value < 0.05) message("DHARMa:testOutliers with type = binomial may have inflated Type I error rates for integer-valued distributions. To get a more exact result, it is recommended to re-run testOutliers with type = 'bootstrap'. See ?testOutliers for details") if(plot == T) { hist(simulationOutput, main = "") main = ifelse(out$p.value <= 0.05, "Outlier test significant", "Outlier test n.s.") title(main = main, cex.main = 1, col.main = ifelse(out$p.value <= 0.05, "red", "black")) } } else { if(margin == "both") outliers = mean(simulationOutput$scaledResiduals == 0) + mean(simulationOutput$scaledResiduals ==1) if(margin == "upper") outliers = mean(simulationOutput$scaledResiduals == 1) if(margin == "lower") outliers = mean(simulationOutput$scaledResiduals ==0) simIndices = 1:simulationOutput$nSim nSim = simulationOutput$nSim if(simulationOutput$refit == T){ simResp = simulationOutput$refittedResiduals } else { simResp = simulationOutput$simulatedResponse } resMethod = simulationOutput$method resInteger = simulationOutput$integerResponse if (nBoot > nSim){ message("DHARMa::testOutliers: nBoot > nSim does not make much sense, thus changed to nBoot = nSim. If you want to increase nBoot, increase nSim in DHARMa::simulateResiduals as well.") nBoot = nSim } frequBoot <- rep(NA, nBoot) for (i in 1:nBoot){ sel = sample(simIndices[-i], size = nSim, replace = T) residuals <- getQuantile(simulations = simResp[,sel], observed = simResp[,i], integerResponse = resInteger, method = resMethod) if(margin == "both") frequBoot[i] = mean(residuals == 1) + mean(residuals == 0) else if(margin == "upper") frequBoot[i] = mean(residuals == 1) else if(margin == "lower") frequBoot[i] = mean(residuals == 0) } out = list() class(out) = "htest" out$alternative = alternative out$p.value = getP(frequBoot, outliers, alternative = alternative) out$conf.int = quantile(frequBoot, c(0.025, 0.975)) out$data.name = data.name out$margin = margin out$method = "DHARMa bootstrapped outlier test" out$statistic = outliers * simulationOutput$nObs names(out$statistic) = paste("outliers at", margin, "margin(s)") out$parameter = simulationOutput$nObs names(out$parameter) = "observations" out$estimate = outliers names(out$estimate) = paste("outlier frequency (expected:", mean(frequBoot),")") if(plot == T) { opar <- par(mfrow = c(1,2)) on.exit(par(opar)) hist(simulationOutput, main = "") main = ifelse(out$p.value <= 0.05, "Outlier test significant", "Outlier test n.s.") title(main = main, cex.main = 1, col.main = ifelse(out$p.value <= 0.05, "red", "black")) hist(frequBoot, xlim = range(frequBoot, outliers), col = "lightgrey") abline(v = mean(frequBoot), col = 1, lwd = 2) abline(v = outliers, col = "red", lwd = 2) } } return(out) } testCategorical <- function(simulationOutput, catPred, quantiles = c(0.25, 0.5, 0.75), plot = T){ simulationOutput = ensureDHARMa(simulationOutput, convert = T) catPred = as.factor(catPred) out = list() out$uniformity$details = suppressWarnings(by(simulationOutput$scaledResiduals, catPred, ks.test, 'punif', simplify = TRUE)) out$uniformity$p.value = rep(NA, nlevels(catPred)) for(i in 1:nlevels(catPred)) out$uniformity$p.value[i] = out$uniformity$details[[i]]$p.value out$uniformity$p.value.cor = p.adjust(out$uniformity$p.value) if(nlevels(catPred) > 1) out$homogeneity = leveneTest(simulationOutput$scaledResiduals ~ catPred) if(plot == T){ boxplot(simulationOutput$scaledResiduals ~ catPred, ylim = c(0,1), axes = FALSE, col = ifelse(out$uniformity$p.value.cor < 0.05, "red", "lightgrey")) axis(1, at = 1:nlevels(catPred), levels(catPred)) axis(2, at=c(0, quantiles, 1)) abline(h = quantiles, lty = 2) } mtext(ifelse(any(out$uniformity$p.value.cor < 0.05), "Within-group deviations from uniformity significant (red)", "Within-group deviation from uniformity n.s."), col = ifelse(any(out$uniformity$p.value.cor < 0.05), "red", "black"), line = 1) if(length(out) > 1) { mtext(ifelse(out$homogeneity$`Pr(>F)`[1] < 0.05, "Levene Test for homogeneity of variance significant", "Levene Test for homogeneity of variance n.s."), col = ifelse(out$homogeneity$`Pr(>F)`[1] < 0.05, "red", "black")) } return(out) } testDispersion <- function(simulationOutput, alternative = c("two.sided", "greater", "less"), plot = T, type = c("DHARMa", "PearsonChisq"), ...){ alternative <- match.arg(alternative) type <- match.arg(type) out = list() out$data.name = deparse(substitute(simulationOutput)) simulationOutput = ensureDHARMa(simulationOutput, convert = "Model") if(type == "DHARMa"){ if(simulationOutput$refit == F){ expectedVar = sd(simulationOutput$simulatedResponse)^2 spread <- function(x) var(x - simulationOutput$fittedPredictedResponse) / expectedVar out = testGeneric(simulationOutput, summary = spread, alternative = alternative, methodName = "DHARMa nonparametric dispersion test via sd of residuals fitted vs. simulated", plot = plot, ...) names(out$statistic) = "dispersion" } else { observed = tryCatch(sum(residuals(simulationOutput$fittedModel, type = "pearson")^2), error = function(e) { message(paste("DHARMa: the requested tests requires pearson residuals, but your model does not implement these calculations. Test will return NA. Error message:", e)) return(NA) }) if(is.na(observed)) return(NA) expected = apply(simulationOutput$refittedPearsonResiduals^2 , 2, sum) out$statistic = c(dispersion = observed / mean(expected)) names(out$statistic) = "dispersion" out$method = "DHARMa nonparametric dispersion test via mean deviance residual fitted vs. simulated-refitted" p = getP(simulated = expected, observed = observed, alternative = alternative) out$alternative = alternative out$p.value = p class(out) = "htest" if(plot == T) { xLabel = paste("Simulated values, red line = fitted model. p-value (",out$alternative, ") = ", out$p.value, sep ="") hist(expected, xlim = range(expected, observed, na.rm=T ), col = "lightgrey", main = "", xlab = xLabel, breaks = 20, cex.main = 1) abline(v = observed, lwd= 2, col = "red") main = ifelse(out$p.value <= 0.05, "Dispersion test significant", "Dispersion test n.s.") title(main = main, cex.main = 1, col.main = ifelse(out$p.value <= 0.05, "red", "black")) } } } else if(type == "PearsonChisq"){ if(! alternative == "greater") message("Note that the chi2 test on Pearson residuals is biased for mixed models towards underdispersion. Tests with alternative = two.sided or less are therefore not reliable. I recommend to test only with alternative = 'greater', i.e. test for overdispersion") rdf <- df.residual(simulationOutput$fittedModel) rp <- residuals(simulationOutput$fittedModel,type="pearson") Pearson.chisq <- sum(rp^2) prat <- Pearson.chisq/rdf if(alternative == "greater") pval <- pchisq(Pearson.chisq, df=rdf, lower.tail=FALSE) else if (alternative == "less") pval <- pchisq(Pearson.chisq, df=rdf, lower.tail=TRUE) else if (alternative == "two.sided") pval <- min(min(pchisq(Pearson.chisq, df=rdf, lower.tail=TRUE), pchisq(Pearson.chisq, df=rdf, lower.tail=FALSE)) * 2,1) out$statistic = prat names(out$statistic) = "dispersion" out$parameter = rdf names(out$parameter) = "df" out$method = "Parametric dispersion test via mean Pearson-chisq statistic" out$alternative = alternative out$p.value = pval class(out) = "htest" return(out) } return(out) } testOverdispersion <- function(simulationOutput, ...){ message("testOverdispersion is deprecated, switch your code to using the testDispersion function") testDispersion(simulationOutput, ...) } testOverdispersionParametric <- function(...){ message("testOverdispersionParametric is deprecated - switch your code to using the testDispersion function") return(0) } testZeroInflation <- function(simulationOutput, ...){ countZeros <- function(x) sum( x == 0) testGeneric(simulationOutput = simulationOutput, summary = countZeros, methodName = "DHARMa zero-inflation test via comparison to expected zeros with simulation under H0 = fitted model", ... ) } testGeneric <- function(simulationOutput, summary, alternative = c("two.sided", "greater", "less"), plot = T, methodName = "DHARMa generic simulation test"){ out = list() out$data.name = deparse(substitute(simulationOutput)) simulationOutput = ensureDHARMa(simulationOutput, convert = "Model") alternative <- match.arg(alternative) observed = summary(simulationOutput$observedResponse) simulated = apply(simulationOutput$simulatedResponse, 2, summary) p = getP(simulated = simulated, observed = observed, alternative = alternative) out$statistic = c(ratioObsSim = observed / mean(simulated)) out$method = methodName out$alternative = alternative out$p.value = p class(out) = "htest" if(plot == T) { plotTitle = gsub('(.{1,50})(\\s|$)', '\\1\n', methodName) xLabel = paste("Simulated values, red line = fitted model. p-value (",out$alternative, ") = ", out$p.value, sep ="") hist(simulated, xlim = range(simulated, observed, na.rm=T ), col = "lightgrey", main = plotTitle, xlab = xLabel, breaks = max(round(simulationOutput$nSim / 5), 20), cex.main = 0.8) abline(v = observed, lwd= 2, col = "red") } return(out) } testTemporalAutocorrelation <- function(simulationOutput, time, alternative = c("two.sided", "greater", "less"), plot = T){ simulationOutput = ensureDHARMa(simulationOutput, convert = T) if(any(duplicated(time))) stop("testing for temporal autocorrelation requires unique time values - if you have several observations per time value, either use the recalculateResiduals function to aggregate residuals per time step, or extract the residuals from the fitted object, and plot / test each of them independently for temporally repeated subgroups (typical choices would be location / subject etc.). Note that the latter must be done by hand, outside testTemporalAutocorrelation.") alternative <- match.arg(alternative) if(is.null(time)){ time = sample.int(simulationOutput$nObs, simulationOutput$nObs) message("DHARMa::testTemporalAutocorrelation - no time argument provided, using random times for each data point") } if (length(time) != length(residuals(simulationOutput))) stop("Dimensions of time don't match the dimension of the residuals") out = lmtest::dwtest(simulationOutput$scaledResiduals ~ 1, order.by = time, alternative = alternative) if(plot == T) { oldpar <- par(mfrow = c(1,2)) on.exit(par(oldpar)) plot(simulationOutput$scaledResiduals[order(time)] ~ time[order(time)], type = "l", ylab = "Scaled residuals", xlab = "Time", main = "Residuals vs. time", ylim = c(0,1)) abline(h=c(0.5)) abline(h=c(0,0.25,0.75,1), lty = 2 ) acf(simulationOutput$scaledResiduals[order(time)], main = "Autocorrelation", ylim = c(-1,1)) legend("topright", c(paste(out$method, " p=", round(out$p.value, digits = 5)), paste("Deviation ", ifelse(out$p.value < 0.05, "significant", "n.s."))), text.col = ifelse(out$p.value < 0.05, "red", "black" ), bty="n") } return(out) } testSpatialAutocorrelation <- function(simulationOutput, x = NULL, y = NULL, distMat = NULL, alternative = c("two.sided", "greater", "less"), plot = T){ alternative <- match.arg(alternative) data.name = deparse(substitute(simulationOutput)) simulationOutput = ensureDHARMa(simulationOutput, convert = T) if(any(duplicated(cbind(x,y)))) stop("testing for spatial autocorrelation requires unique x,y values - if you have several observations per location, either use the recalculateResiduals function to aggregate residuals per location, or extract the residuals from the fitted object, and plot / test each of them independently for spatially repeated subgroups (a typical scenario would repeated spatial observation, in which case one could plot / test each time step separately for temporal autocorrelation). Note that the latter must be done by hand, outside testSpatialAutocorrelation.") if( (!is.null(x) | !is.null(y)) & !is.null(distMat) ) message("both coordinates and distMat provided, calculations will be done based on the distance matrix, coordinates will only be used for plotting") if( (is.null(x) | is.null(y)) & is.null(distMat) ) stop("You need to provide either x,y, coordinates, or a distMatrix") if(is.null(distMat) & (length(x) != length(residuals(simulationOutput)) | length(y) != length(residuals(simulationOutput)))) if (!is.null(x) & length(x) != length(residuals(simulationOutput)) | !is.null(y) & length(y) != length(residuals(simulationOutput))) stop("Dimensions of x / y coordinates don't match the dimension of the residuals") if(is.null(distMat)) distMat <- as.matrix(dist(cbind(x, y))) invDistMat <- 1/distMat diag(invDistMat) <- 0 MI = ape::Moran.I(simulationOutput$scaledResiduals, weight = invDistMat, alternative = alternative) out = list() out$statistic = c(observed = MI$observed, expected = MI$expected, sd = MI$sd) out$method = "DHARMa Moran's I test for distance-based autocorrelation" out$alternative = "Distance-based autocorrelation" out$p.value = MI$p.value out$data.name = data.name class(out) = "htest" if(plot == T & !is.null(x) & !is.null(y)) { opar <- par(mfrow = c(1,1)) on.exit(par(opar)) col = colorRamp(c("red", "white", "blue"))(simulationOutput$scaledResiduals) plot(x,y, col = rgb(col, maxColorValue = 255), main = out$method, cex.main = 0.8 ) } return(out) } getP <- function(simulated, observed, alternative, plot = F){ if(alternative == "greater") p = mean(simulated >= observed) if(alternative == "less") p = mean(simulated <= observed) if(alternative == "two.sided") p = min(min(mean(simulated <= observed), mean(simulated >= observed) ) * 2,1) if(plot == T){ hist(simulated, xlim = range(simulated, observed), col = "lightgrey") abline(v = mean(simulated), col = 1, lwd = 2) abline(v = observed, col = "red", lwd = 2) } return(p) }
runmed <- function(x, k, endrule = c("median","keep","constant"), algorithm = NULL, print.level = 0) { n <- as.integer(length(x)) if(is.na(n)) stop("invalid value of length(x)") k <- as.integer(k) if(is.na(k)) stop("invalid value of 'k'") if(k < 0L) stop("'k' must be positive") if(k %% 2L == 0L) warning(gettextf("'k' must be odd! Changing 'k' to %d", k <- as.integer(1+ 2*(k %/% 2))), domain = NA) if(n == 0L) { x <- double(); attr(x, "k") <- k return(x) } if (k > n) warning(gettextf("'k' is bigger than 'n'! Changing 'k' to %d", k <- as.integer(1+ 2*((n - 1)%/% 2))), domain = NA) algorithm <- if(missing(algorithm)) { if(k < 20L || n < 300L) "Stuetzle" else "Turlach" } else match.arg(algorithm, c("Stuetzle", "Turlach")) endrule <- match.arg(endrule) iend <- switch(endrule, "median" =, "keep" = 0L, "constant" = 1L) if(print.level) cat("runmed(*, endrule=", endrule,", algorithm=",algorithm, ", iend=",iend,")\n") res <- switch(algorithm, Turlach = .Call(C_runmed, as.double(x), 1, k, iend, print.level), Stuetzle = .Call(C_runmed, as.double(x), 0, k, iend, print.level)) if(endrule == "median") res <- smoothEnds(res, k = k) attr(res,"k") <- k res } smoothEnds <- function(y, k = 3) { med3 <- function(a,b,c) { m <- b if (a < b) { if (c < b) m <- if (a >= c) a else c } else { if (c > b) m <- if (a <= c) a else c } m } med.odd <- function(x, n = length(x)) { half <- (n + 1) %/% 2 sort(x, partial = half)[half] } k <- as.integer(k) if (k < 0L || k %% 2L == 0L) stop("bandwidth 'k' must be >= 1 and odd!") k <- k %/% 2L if (k < 1L) return(y) n <- length(y) sm <- y if (k >= 2L) { sm [2L] <- med3(y[1L],y [2L], y [3L]) sm[n-1L] <- med3(y[n],y[n-1L],y[n-2L]) if (k >= 3L) { for (i in 3:k) { j <- 2L*i - 1L sm [i] <- med.odd( y [1L:j] , j) sm[n-i+1L] <- med.odd( y[(n+1L-j):n], j) } } } sm[1L] <- med3(y[1L], sm [2L] , 3*sm [2L] - 2*sm [3L]) sm[n] <- med3(y[n], sm[n-1L], 3*sm[n-1L] - 2*sm[n-2L]) sm }
getVal <- function(x, vars = "both"){ if(class(x) != "chaos01.res"){ stop("Input variable is not of class 'chaos01.res' (list of results of class 'chaos01').") } switch(vars, "Kc" = return(sapply(x, function(y)y$Kc)), "c" = return(sapply(x, function(y)y$c)), "both" = { kc <- sapply(x, function(y)y$Kc) c <- sapply(x, function(y)y$c) return(data.frame(c = c, kc = kc)) } ) }
suppressAll = function(expr) { capture.output({ z = suppressWarnings( suppressMessages( suppressPackageStartupMessages(force(expr)) ) ) }) invisible(z) }
local_repo_push = function(repo_dir, remote = "origin", branch = NULL, force = FALSE, prompt = TRUE, mirror = FALSE, verbose = FALSE) { require_gert() arg_is_chr(repo_dir, remote) arg_is_chr(branch, allow_null = TRUE) arg_is_lgl_scalar(verbose) if (is.null(branch)) branch = list(NULL) dir = repo_dir_helper(repo_dir) res = purrr::pmap( list(dir, remote, branch), function(dir, remote, branch) { if (is.null(branch)) branch = gert::git_info(repo = dir)$shorthand repo = fs::path_file(dir) if (is.na(branch)) ref = remote else ref = paste(remote, branch, sep="/") run = TRUE if (prompt & force) { remotes = gert::git_remote_list(repo_dir) repo = remotes$url[remotes$name == remote] run = cli_yeah("This command will overwrite the branch {.val {branch}} from repo {.val {repo}}.") } if (!run) { cli::cli_alert_danger("User canceled force push (overwrite) of {.val {ref}}") return(NULL) } res = purrr::safely(gert::git_push)( remote = remote, refspec = glue::glue("refs/heads/{branch}:refs/heads/{branch}"), repo = dir, force = force, mirror = mirror, verbose = verbose ) status_msg( res, "Pushed from local repo {.val {fs::path_file(repo)}} to {.val {ref}}.", "Failed to push from local repo {.val {repo}} to {.val {ref}}." ) res } ) invisible(res) }
context("Checking blank2NA") test_that("blank2NA gives the desired output and replaces empty cells",{ set.seed(15) dat <- data.frame(matrix(sample(c(month.abb[1:4], ""), 50, TRUE), 10, byrow = TRUE), stringsAsFactors = FALSE) expect_true(any(sapply(dat, function(x) any(na.omit(x) == "")))) expect_true(is.data.frame(blank2NA(dat))) expect_false(any(sapply(blank2NA(dat), function(x) any(na.omit(x) == "")))) })
touchstep<-function(node,curroot,boundrec,child,sibling,infopointer, low,upp,rho=0) { d<-length(low[1,]) comprec<-matrix(0,2*d,1) note<-infopointer[node] for (i in 1:d){ comprec[2*i-1]<-low[note,i] comprec[2*i]<-upp[note,i] } itemnum<-length(child) pino<-matrix(0,itemnum,1) potetouch<-1 istouch<-0 pino[1]<-curroot pinin<-1 while ((pinin>0) && (istouch==0)){ cur<-pino[pinin] pinin<-pinin-1 currec<-boundrec[cur,] pointrec<-matrix(0,2*d,1) note<-infopointer[cur] for (i in 1:d){ pointrec[2*i-1]<-low[note,i] pointrec[2*i]<-upp[note,i] } potetouch<-touchi(comprec,currec,rho) istouch<-touchi(comprec,pointrec,rho) if (sibling[cur]>0){ pinin<-pinin+1 pino[pinin]<-sibling[cur] } while ((child[cur]>0) && (istouch==0) && (potetouch==1)){ cur<-child[cur] currec<-boundrec[cur,] pointrec<-matrix(0,2*d,1) note<-infopointer[cur] for (i in 1:d){ pointrec[2*i-1]<-low[note,i] pointrec[2*i]<-upp[note,i] } potetouch<-touchi(comprec,currec,rho) istouch<-touchi(comprec,pointrec,rho) if (sibling[cur]>0){ pinin<-pinin+1 pino[pinin]<-sibling[cur] } } } return(istouch) }
exportSurveyParticipants <- function(rcon, instrument, event, ...){ UseMethod("importArms") } exportSurveyParticipants.redcapDbConnection <- function(rcon, instrument, event, ...){ message("Please accept my apologies. The importArms method for redcapDbConnection objects\n", "has not yet been written. Please consider using the API.") } exportSurveyParticipants.redcapApiConnection <- function(rcon, instrument, event, ..., error_handling = getOption("redcap_error_handling")){ .params <- list(token=rcon$token, instrument = instrument, event = event, content='participantList', format='csv', returnFormat='csv') x <- httr::POST(url=rcon$url, body=.params, config=rcon$config) if (x$status_code != 200) return(redcap_error(x, error_handling)) x <- utils::read.csv(textConnection(as.character(x)), stringsAsFactors=FALSE, na.strings="") return(x) }
theme_ipsum_pub <- function( base_family="Public Sans", base_size = 10.5, plot_title_family=if (.Platform$OS.type == "windows") "Public Sans" else "Public Sans Bold", plot_title_size = 18, plot_title_face="bold", plot_title_margin = 10, subtitle_family=if (.Platform$OS.type == "windows") "Public Sans Thin" else "Public Sans Thin", subtitle_size = 13, subtitle_face = "plain", subtitle_margin = 15, strip_text_family = base_family, strip_text_size = 12, strip_text_face = "plain", caption_family=if (.Platform$OS.type == "windows") "Public Sans Thin" else "Public Sans Thin", caption_size = 9, caption_face = "plain", caption_margin = 10, axis_text_size = base_size, axis_title_family = base_family, axis_title_size = 9, axis_title_face = "plain", axis_title_just = "rt", plot_margin = margin(30, 30, 30, 30), grid_col = " axis_col = " ret <- ggplot2::theme_minimal(base_family=base_family, base_size=base_size) ret <- ret + theme(legend.background=element_blank()) ret <- ret + theme(legend.key=element_blank()) if (inherits(grid, "character") | grid == TRUE) { ret <- ret + theme(panel.grid=element_line(color=grid_col, size=0.2)) ret <- ret + theme(panel.grid.major=element_line(color=grid_col, size=0.2)) ret <- ret + theme(panel.grid.minor=element_line(color=grid_col, size=0.15)) if (inherits(grid, "character")) { if (regexpr("X", grid)[1] < 0) ret <- ret + theme(panel.grid.major.x=element_blank()) if (regexpr("Y", grid)[1] < 0) ret <- ret + theme(panel.grid.major.y=element_blank()) if (regexpr("x", grid)[1] < 0) ret <- ret + theme(panel.grid.minor.x=element_blank()) if (regexpr("y", grid)[1] < 0) ret <- ret + theme(panel.grid.minor.y=element_blank()) } } else { ret <- ret + theme(panel.grid=element_blank()) } if (inherits(axis, "character") | axis == TRUE) { ret <- ret + theme(axis.line=element_line(color=axis_col, size=0.15)) if (inherits(axis, "character")) { axis <- tolower(axis) if (regexpr("x", axis)[1] < 0) { ret <- ret + theme(axis.line.x=element_blank()) } else { ret <- ret + theme(axis.line.x=element_line(color=axis_col, size=0.15)) } if (regexpr("y", axis)[1] < 0) { ret <- ret + theme(axis.line.y=element_blank()) } else { ret <- ret + theme(axis.line.y=element_line(color=axis_col, size=0.15)) } } else { ret <- ret + theme(axis.line.x=element_line(color=axis_col, size=0.15)) ret <- ret + theme(axis.line.y=element_line(color=axis_col, size=0.15)) } } else { ret <- ret + theme(axis.line=element_blank()) } if (!ticks) { ret <- ret + theme(axis.ticks = element_blank()) ret <- ret + theme(axis.ticks.x = element_blank()) ret <- ret + theme(axis.ticks.y = element_blank()) } else { ret <- ret + theme(axis.ticks = element_line(size=0.15)) ret <- ret + theme(axis.ticks.x = element_line(size=0.15)) ret <- ret + theme(axis.ticks.y = element_line(size=0.15)) ret <- ret + theme(axis.ticks.length = grid::unit(5, "pt")) } xj <- switch(tolower(substr(axis_title_just, 1, 1)), b=0, l=0, m=0.5, c=0.5, r=1, t=1) yj <- switch(tolower(substr(axis_title_just, 2, 2)), b=0, l=0, m=0.5, c=0.5, r=1, t=1) ret <- ret + theme(axis.text.x=element_text(size=axis_text_size, margin=margin(t=0))) ret <- ret + theme(axis.text.y=element_text(size=axis_text_size, margin=margin(r=0))) ret <- ret + theme(axis.title=element_text(size=axis_title_size, family=axis_title_family)) ret <- ret + theme(axis.title.x=element_text(hjust=xj, size=axis_title_size, family=axis_title_family, face=axis_title_face)) ret <- ret + theme(axis.title.y=element_text(hjust=yj, size=axis_title_size, family=axis_title_family, face=axis_title_face)) ret <- ret + theme(axis.title.y.right=element_text(hjust=yj, size=axis_title_size, angle=90, family=axis_title_family, face=axis_title_face)) ret <- ret + theme(strip.text=element_text(hjust=0, size=strip_text_size, face=strip_text_face, family=strip_text_family)) ret <- ret + theme(panel.spacing=grid::unit(2, "lines")) ret <- ret + theme(plot.title=element_text(hjust=0, size=plot_title_size, margin=margin(b=plot_title_margin), family=plot_title_family, face=plot_title_face)) ret <- ret + theme(plot.subtitle=element_text(hjust=0, size=subtitle_size, margin=margin(b=subtitle_margin), family=subtitle_family, face=subtitle_face)) ret <- ret + theme(plot.caption=element_text(hjust=1, size=caption_size, margin=margin(t=caption_margin), family=caption_family, face=caption_face)) ret <- ret + theme(plot.margin=plot_margin) ret } import_public_sans <- function() { pub_font_dir <- system.file("fonts", "public-sans", package="hrbrthemes") suppressWarnings(suppressMessages(extrafont::font_import(pub_font_dir, prompt=FALSE))) message( sprintf( "You will likely need to install these fonts on your system as well.\n\nYou can find them in [%s]", pub_font_dir) ) } font_pub <- "Public Sans" font_pub_bold <- "Public Sans Bold" font_pub_light <- "Public Sans Light" font_pub_thin <- "Public Sans Thin"
iexp <- function(u = runif(1), rate = 1, minPlotQuantile = 0, maxPlotQuantile = 0.99, plot = TRUE, showCDF = TRUE, showPDF = TRUE, showECDF = TRUE, show = NULL, maxInvPlotted = 50, plotDelay = 0, sampleColor = "red3", populationColor = "grey", showTitle = TRUE, respectLayout = FALSE, ...) { if(is.null(dev.list())) dev.new(width=5, height=6) warnVal <- options("warn") oldpar <- par(no.readonly = TRUE) options(warn = -1) if (!is.null(u) && (min(u) <= 0 || max(u) >= 1)) stop("must have 0 < u < 1") if (length(u) == 0) u <- NULL checkVal(rate, minex = 0) checkQuants(minPlotQuantile, maxPlotQuantile, min = 0, maxex = 1) options(warn = 1) for (arg in names(list(...))) { if (arg == "maxPlotTime") warning("'maxPlotTime' has been deprecated as of simEd v2.0.0") else stop(paste("Unknown argument '", arg, "'", sep = "")) } getDensity <- function(d) dexp(d, rate) getDistro <- function(d) pexp(d, rate) getQuantile <- function(d) qexp(d, rate) titleStr <- paste("Exponential (", sym$lambda, " = ", round(rate, 3), ")", sep = "") out <- PlotContinuous( u = u, minPlotQuantile = minPlotQuantile, maxPlotQuantile = maxPlotQuantile, plot = plot, showCDF = showCDF, showPDF = showPDF, showECDF = showECDF, show = show, maxInvPlotted = maxInvPlotted, plotDelay = plotDelay, sampleColor = sampleColor, populationColor = populationColor, showTitle = showTitle, respectLayout = respectLayout, getDensity = getDensity, getDistro = getDistro, getQuantile = getQuantile, hasCDF = !missing(showCDF), hasPDF = !missing(showPDF), hasECDF = !missing(showECDF), titleStr = titleStr ) options(warn = warnVal$warn) if (!all(oldpar$mfrow == par()$mfrow)) { par(mfrow = oldpar$mfrow) } if (!is.null(out)) return(out) }
range.default <- function(..., na.rm = FALSE, finite = FALSE) { x <- c(..., recursive = TRUE) if(is.numeric(x)) { if(finite) x <- x[is.finite(x)] else if(na.rm) x <- x[!is.na(x)] return (c(min(x), max(x))) } c(min(x, na.rm=na.rm), max(x, na.rm=na.rm)) }
prepareData <- function(Z, fact = NA, ordfact, ordering = NA, intercept = TRUE){ if (identical(NA, ordering) == TRUE){ordering <- rep("i", length(ordfact))} Z <- as.matrix(Z) if (intercept == TRUE){ Z <- cbind("intercept" = 1, Z) fact <- fact + 1 ordfact <- ordfact + 1 } ordfact.orig <- ordfact if (is.na(max(fact)) == 0){ u.f <- length(fact) u.kj <- NULL for (l in 1:u.f){u.kj[l] <- length(apply(as.matrix(Z[, fact[l]]), 2, table))} Y <- cbind(Z[, -c(fact, ordfact)]) for (l in 1:u.f){Y <- cbind(Y, dummy(Z[, fact[l]], dimnames(Z)[[2]][fact[l]]))} ordfact <- length(Y[1, ]) + (1:length(ordfact)) Z <- cbind(Y, Z[, ordfact.orig]) } n <- dim(Z)[1] p <- dim(Z)[2] f <- length(ordfact) kj <- NULL for (l in 1:f){kj[l] <- length(apply(as.matrix(Z[, ordfact[l]]), 2, table))} JJs <- indexDummy(kj, f, p) Y <- cbind(Z[, -ordfact]) for (l in 1:f){Y <- cbind(Y, dummy(Z[, ordfact[l]], dimnames(Z)[[2]][ordfact[l]]))} for (u in 1:length(JJs)){if (ordering[u] == "d"){Y[, JJs[[u]]] <- Y[, rev(JJs[[u]])]}} m <- dim(Y)[2] return(list("Z" = Z, "Y" = Y, "ordfact" = ordfact, "n" = n, "p" = p, "m" = m, "f" = f, "kj" = kj, "JJs" = JJs)) }
make_arima_reg <- function() { parsnip::set_new_model("arima_reg") parsnip::set_model_mode("arima_reg", "regression") parsnip::set_model_engine("arima_reg", mode = "regression", eng = "arima") parsnip::set_dependency("arima_reg", "arima", "forecast") parsnip::set_dependency("arima_reg", "arima", "modeltime") parsnip::set_model_arg( model = "arima_reg", eng = "arima", parsnip = "seasonal_period", original = "period", func = list(pkg = "modeltime", fun = "seasonal_period"), has_submodel = FALSE ) parsnip::set_model_arg( model = "arima_reg", eng = "arima", parsnip = "non_seasonal_ar", original = "p", func = list(pkg = "modeltime", fun = "non_seasonal_ar"), has_submodel = FALSE ) parsnip::set_model_arg( model = "arima_reg", eng = "arima", parsnip = "non_seasonal_differences", original = "d", func = list(pkg = "modeltime", fun = "non_seasonal_differences"), has_submodel = FALSE ) parsnip::set_model_arg( model = "arima_reg", eng = "arima", parsnip = "non_seasonal_ma", original = "q", func = list(pkg = "modeltime", fun = "non_seasonal_ma"), has_submodel = FALSE ) parsnip::set_model_arg( model = "arima_reg", eng = "arima", parsnip = "seasonal_ar", original = "P", func = list(pkg = "modeltime", fun = "seasonal_ar"), has_submodel = FALSE ) parsnip::set_model_arg( model = "arima_reg", eng = "arima", parsnip = "seasonal_differences", original = "D", func = list(pkg = "modeltime", fun = "seasonal_differences"), has_submodel = FALSE ) parsnip::set_model_arg( model = "arima_reg", eng = "arima", parsnip = "seasonal_ma", original = "Q", func = list(pkg = "modeltime", fun = "seasonal_ma"), has_submodel = FALSE ) parsnip::set_encoding( model = "arima_reg", eng = "arima", mode = "regression", options = list( predictor_indicators = "none", compute_intercept = FALSE, remove_intercept = FALSE, allow_sparse_x = FALSE ) ) parsnip::set_fit( model = "arima_reg", eng = "arima", mode = "regression", value = list( interface = "data.frame", protect = c("x", "y"), func = c(fun = "Arima_fit_impl"), defaults = list(method = "ML") ) ) parsnip::set_pred( model = "arima_reg", eng = "arima", mode = "regression", type = "numeric", value = list( pre = NULL, post = NULL, func = c(fun = "predict"), args = list( object = rlang::expr(object$fit), new_data = rlang::expr(new_data) ) ) ) parsnip::set_model_engine("arima_reg", mode = "regression", eng = "auto_arima") parsnip::set_dependency("arima_reg", "auto_arima", "forecast") parsnip::set_dependency("arima_reg", "auto_arima", "modeltime") parsnip::set_model_arg( model = "arima_reg", eng = "auto_arima", parsnip = "seasonal_period", original = "period", func = list(pkg = "modeltime", fun = "seasonal_period"), has_submodel = FALSE ) parsnip::set_model_arg( model = "arima_reg", eng = "auto_arima", parsnip = "non_seasonal_ar", original = "max.p", func = list(pkg = "modeltime", fun = "non_seasonal_ar"), has_submodel = FALSE ) parsnip::set_model_arg( model = "arima_reg", eng = "auto_arima", parsnip = "non_seasonal_differences", original = "max.d", func = list(pkg = "modeltime", fun = "non_seasonal_differences"), has_submodel = FALSE ) parsnip::set_model_arg( model = "arima_reg", eng = "auto_arima", parsnip = "non_seasonal_ma", original = "max.q", func = list(pkg = "modeltime", fun = "non_seasonal_ma"), has_submodel = FALSE ) parsnip::set_model_arg( model = "arima_reg", eng = "auto_arima", parsnip = "seasonal_ar", original = "max.P", func = list(pkg = "modeltime", fun = "seasonal_ar"), has_submodel = FALSE ) parsnip::set_model_arg( model = "arima_reg", eng = "auto_arima", parsnip = "seasonal_differences", original = "max.D", func = list(pkg = "modeltime", fun = "seasonal_differences"), has_submodel = FALSE ) parsnip::set_model_arg( model = "arima_reg", eng = "auto_arima", parsnip = "seasonal_ma", original = "max.Q", func = list(pkg = "modeltime", fun = "seasonal_ma"), has_submodel = FALSE ) parsnip::set_encoding( model = "arima_reg", eng = "auto_arima", mode = "regression", options = list( predictor_indicators = "none", compute_intercept = FALSE, remove_intercept = FALSE, allow_sparse_x = FALSE ) ) parsnip::set_fit( model = "arima_reg", eng = "auto_arima", mode = "regression", value = list( interface = "data.frame", protect = c("x", "y"), func = c(fun = "auto_arima_fit_impl"), defaults = list() ) ) parsnip::set_pred( model = "arima_reg", eng = "auto_arima", mode = "regression", type = "numeric", value = list( pre = NULL, post = NULL, func = c(fun = "predict"), args = list( object = rlang::expr(object$fit), new_data = rlang::expr(new_data) ) ) ) }
sar_chapman <- function(data, start = NULL, grid_start = "partial", grid_n = NULL, normaTest = "none", homoTest = "none", homoCor = "spearman", verb = TRUE){ if (!(is.matrix(data) | is.data.frame(data))) stop('data must be a matrix or dataframe') if (is.matrix(data)) data <- as.data.frame(data) if (anyNA(data)) stop('NAs present in data') normaTest <- match.arg(normaTest, c('none', 'shapiro', 'kolmo', 'lillie')) homoTest <- match.arg(homoTest, c('none', 'cor.area', 'cor.fitted')) if (homoTest != 'none'){ homoCor <- match.arg(homoCor, c('spearman', 'pearson', 'kendall')) } if (!(grid_start %in% c('none', 'partial', 'exhaustive'))){ stop('grid_start should be one of none, partial or exhaustive') } if (grid_start == 'exhaustive'){ if (!is.numeric(grid_n)) stop('grid_n should be numeric if grid_start == exhaustive') } if (!is.logical(verb)){ stop('verb should be logical') } data <- data[order(data[,1]),] colnames(data) <- c('A','S') xr <- range(data$S)/mean(data$S) if (isTRUE(all.equal(xr[1], xr[2]))) { if (data$S[1] == 0){ warning('All richness values are zero: parameter estimates of', ' non-linear models should be interpreted with caution') } else{ warning('All richness values identical') }} model <- list( name = c("Chapman Richards"), formula = expression(S == d * (1 - exp(-z*A))^c), exp = expression(d * (1 - exp(-z*A))^c), shape = "sigmoid", asymp = function(pars)pars["d"], parLim = c("Rplus","R","R"), init = function(data){ d=max(data$S) Z=(-log((-data$S/(max(data$S)+1))+1))/data$A z = mean(Z) c(d,z,0.5)} ) model <- compmod(model) fit <- get_fit(model = model, data = data, start = start, grid_start = grid_start, grid_n = grid_n, algo = 'Nelder-Mead', normaTest = normaTest, homoTest = homoTest, homoCor = homoCor, verb = verb) if(is.na(fit$value)){ return(list(value = NA)) }else{ obs <- obs_shape(fit, verb = verb) fit$observed_shape <- obs$fitShape fit$asymptote <- obs$asymp fit$neg_check <- any(fit$calculated < 0) class(fit) <- 'sars' attr(fit, 'type') <- 'fit' return(fit) } }
hyper_vars <- function(x, ...) { out <- x[["variable"]] %>% dplyr::filter(.data$active) out[["active"]] <- NULL out } hyper_dims <- function(x, ...) { act <- hyper_transforms(x) out <- tibble::tibble(name = names(act), length = unlist(lapply(act, nrow)), start = unlist(lapply(act, function(a) which(a$selected)[1])), count = unlist(lapply(act, function(a) sum(a$selected)))) act1 <- x$dimension %>% dplyr::filter(.data$active) act1[c("active", "start", "count")] <- NULL dplyr::inner_join(out, act1, c("length", "name")) } hyper_grids <- function(x, ...) { x$grid[c("grid", "ndims", "nvars")] %>% mutate(active = .data$grid == active(x)) }
qqskewlap <- function(y, mu = 0, alpha = 1, beta = 1, param = c(mu, alpha, beta), main = "Skew-Laplace Q-Q Plot", xlab = "Theoretical Quantiles", ylab = "Sample Quantiles", plot.it = TRUE, line = TRUE, ...) { if (has.na <- any(ina <- is.na(y))) { yN <- y y <- y[!ina] } if ((n <- length(y)) == 0) stop("y is empty or has only NAs") x <- qskewlap(ppoints(n), param = param)[order(order(y))] if (has.na) { y <- x x <- yN x[!ina] <- y y <- yN } if (plot.it) { plot(x, y, main = main, xlab = xlab, ylab = ylab, ...) title(sub = paste("param = (", round(param[1], 3), ", ", round(param[2], 3), ", ", round(param[3], 3), ")", sep = "")) if (line) abline(0, 1) } invisible(list(x = x, y = y)) } ppskewlap <- function(y, mu = 0, alpha = 1, beta = 1, param = c(mu, alpha, beta), main = "Skew-Laplace P-P Plot", xlab = "Uniform Quantiles", ylab = "Probability-integral-transformed Data", plot.it = TRUE, line = TRUE, ...) { if (has.na <- any(ina <- is.na(y))) { yN <- y y <- y[!ina] } if ((n <- length(y)) == 0) stop("data is empty") yvals <- pskewlap(y, param = param) xvals <- ppoints(n, a = 1 / 2)[order(order(y))] if (has.na) { y <- yvals x <- xvals yvals <- yN yvals[!ina] <- y xvals <- yN xvals[!ina] <- x } if (plot.it) { plot(xvals, yvals, main = main, xlab = xlab, ylab = ylab, ylim = c(0, 1), xlim = c(0, 1), ...) title(sub = paste("param = (", round(param[1], 3), ", ", round(param[2], 3), ", ", round(param[3], 3), ")", sep = "")) if (line) abline(0, 1) } invisible(list(x = xvals, y = yvals)) }
do.isoproj <- function(X,ndim=2,type=c("proportion",0.1), symmetric=c("union","intersect","asymmetric"), preprocess=c("center","scale","cscale","decorrelate","whiten")){ aux.typecheck(X) if ((!is.numeric(ndim))||(ndim<1)||(ndim>ncol(X))||is.infinite(ndim)||is.na(ndim)){ stop("*do.isoproj : 'ndim' is a positive integer in [1, } ndim = as.integer(ndim) nbdtype = type if (missing(symmetric)){ nbdsymmetric = "union" } else { nbdsymmetric = match.arg(symmetric) } algweight = TRUE if (missing(preprocess)){ algpreprocess = "center" } else { algpreprocess = match.arg(preprocess) } tmplist = aux.preprocess.hidden(X,type=algpreprocess,algtype="linear") trfinfo = tmplist$info pX = tmplist$pX nbdstruct = aux.graphnbd(pX,method="euclidean", type=nbdtype,symmetric=nbdsymmetric) D = nbdstruct$dist Dmask = nbdstruct$mask nD = ncol(D) if (algweight){ wD = Dmask*D idnan = is.na(wD) wD[idnan] = 0 } else { wD = matrix(as.double(Dmask),nrow=nD) } sD = aux.shortestpath(wD) rDG = convert_gram(sD) workdim = RSpectra::svds(t(pX), ndim) if (workdim$d[ndim] <= 0){ message("do.isoproj : effective rank of input matrix X is less than 'ndim'. Change 'ndim' correspondingly.") ndim = sum((workdim$d>0)) } U = workdim$u[,1:ndim] V = workdim$v[,1:ndim] Xbar = t(pX%*%U) LHS = Xbar%*%rDG%*%t(Xbar) RHS = Xbar%*%t(Xbar) SOL = base::solve(LHS, RHS) if (ndim<3){ res = base::eigen(SOL, ndim) A = U%*%(res$vectors[,1:ndim]) } else { res = RSpectra::eigs_sym(SOL, ndim, which="LA") A = U%*%(res$vectors) } projection = aux.adjprojection(A) result = list() result$Y = pX%*%projection result$projection = projection result$trfinfo = trfinfo return(result) } convert_gram <- function(D){ m = nrow(D) H = diag(x=1,m,m)-(outer(rep(1,m),rep(1,m))/m) S = (D^2) return((-H%*%S%*%H)/2) }
imputeBasic <- function(data, Init = "mean") { dat <- data dat1a <- dat[(sapply(dat, function(x) is.numeric(x)) == T)] if(ncol(dat1a) != 0) { if(Init == "mean") { dat1 <- as.data.frame(apply(dat1a, 2, function(x) ifelse(is.na(x), mean(x, na.rm = TRUE), x))) } else { dat1 <- as.data.frame(apply(dat1a, 2, function(x) ifelse(is.na(x), median(x, na.rm = TRUE), x))) } Initials <- dat1[sapply(dat1a, function(x) is.na(x))] } else { Initials <- "No Continous Variables in Dataset" dat1 <- dat1a } dat.factors.a <- dat[(sapply(dat, function(x) is.factor(x)) == T)] if(ncol(dat.factors.a) > 0) { dat.factors.b <- apply(dat.factors.a, 2, function(x) ifelse(x == "" | is.na(x), "Missing", x)) dat.factors <- data.frame(sapply(1:ncol(dat.factors.b), function(x) as.factor(dat.factors.b[, x]))) names(dat.factors) <- names(dat.factors.a) my.cols <- names(dat.factors) Imputed.Factor.Levels <- sapply(my.cols, function(this.col) { B <- table(dat.factors[, this.col]) NL <- sort(B[names(B) != "Missing"], decreasing = T) NL2 <- names(NL)[1] }) dat2 <- as.data.frame(sapply(1:length(Imputed.Factor.Levels), function(this.col) { NL2 <- levels(as.factor((as.character(Imputed.Factor.Levels))[this.col])) levels(dat.factors[, this.col])[levels(dat.factors[, this.col]) == "Missing"] <- NL2 dat.factors[, this.col] })); names(dat2) <- names(dat.factors) dat[, names(dat2)] <- dat2 dat.cat.imp <- dat dat[, names(dat1)] <- dat1 output <- list(Imputed.DataFrame = dat, Imputed.Missing.Continous = Initials, Imputed.Missing.Factors = Imputed.Factor.Levels) } else { Imputed.Factor.Levels <- "No Categorical Variables in Dataset" dat <- dat1 output <- list(Imputed.DataFrame = dat, Imputed.Missing.Continous = Initials, Imputed.Missing.Factors = NA) } class(output) <- "roughImputation" output } print.roughImputation <- function(x, ...) { print(x$Imputed.DataFrame) }
plot_beta <- function(alpha, beta, mean = FALSE, mode = FALSE){ p <- ggplot(data = data.frame(x = c(0, 1)), aes(x)) + stat_function(fun = stats::dbeta, n = 101, args = list(shape1 = alpha, shape2=beta)) + labs(x = expression(pi), y = expression(paste("f(",pi,")"))) if (mean == TRUE & mode == FALSE){ mean <- alpha / (alpha + beta) p <- p + geom_segment(aes(x = mean, y = 0, xend = mean, yend = dbeta(mean, alpha, beta), linetype = "mean")) + scale_linetype_manual(values = c(mean = "solid")) + theme(legend.title = element_blank()) } if (mean == FALSE & mode == TRUE){ mode <- (alpha - 1)/(alpha + beta - 2) p <- p + geom_segment(aes(x = mode, y = 0, xend = mode, yend = dbeta(mode, alpha, beta), linetype = "mode"))+ scale_linetype_manual(values = c(mode = "dashed")) + theme(legend.title = element_blank()) } if (mean == TRUE & mode == TRUE){ mean <- alpha / (alpha + beta) mode <- (alpha - 1)/(alpha + beta - 2) p <- p + geom_segment(aes(x = mean, y = 0, xend = mean, yend = dbeta(mean, alpha, beta), linetype = "mean")) + geom_segment(aes(x = mode, y = 0, xend = mode, yend = stats::dbeta(mode, alpha, beta), linetype = "mode"))+ scale_linetype_manual(values = c(mean = "solid", mode = "dashed")) + theme(legend.title = element_blank()) } p }
writeFlapjack <- function(IBDprob, outFileMap = "ibd_map.txt", outFileGeno = "ibd_geno.txt") { if (!inherits(IBDprob, "IBDprob")) { stop("IBDprob should be an object of class IBDprob.\n") } chkFile(outFileMap, fileType = "txt") chkFile(outFileGeno, fileType = "txt") map <- IBDprob$map markers <- IBDprob$markers parents <- IBDprob$parents nPar <- length(parents) nGeno <- dim(markers)[[2]] nMarkers <- dim(markers)[[1]] mrk1 <- rownames(markers)[1] parVals <- colnames(getProbs(IBDprob, mrk1))[-1] parVals <- gsub(pattern = paste0(mrk1, "_"), replacement = "", x = parVals) for (i in seq_along(parents)) { parVals <- gsub(pattern = parents[i], replacement = paste0(i, "/"), x = parVals) } parVals <- substring(parVals, first = 1, last = nchar(parVals) - 1) res <- sapply(X = rownames(markers), FUN = function(marker) { mrkProbs <- getProbs(IBDprob, marker)[-1] apply(mrkProbs, MARGIN = 1, FUN = function(x) { if (length(which(x > (0.5 + 0.15 / nPar))) == 1) { parVals[which.max(x)] } else { "-" } }) }) res <- matrix(data = res, nrow = nGeno, dimnames = dimnames(markers)[2:1]) resPar <- matrix(data = seq_along(parents), nrow = nPar, ncol = nMarkers, dimnames = list(parents, dimnames(markers)[[1]])) res <- rbind(resPar, res) cat(file = outFileMap, " write.table(map, file = outFileMap, quote = FALSE, sep = "\t", na = "-", row.names = TRUE, col.names = FALSE, append = TRUE) cat(file = outFileGeno, " cat(colnames(res), file = outFileGeno, sep = "\t", append = TRUE) cat("\n", file = outFileGeno, append = TRUE) write.table(res, file = outFileGeno, quote = FALSE, sep = "\t", na = "-", row.names = TRUE, col.names = FALSE, append = TRUE) }
SemiParROY.fit.post <- function(SemiParFit, Model, VC, GAM){ Ve <- R <- X4s <- X5s <- X6s <- X7s <- X8s <- X9s <- eta1S <- eta2S <- theta1 <- theta2 <- edf <- edf1 <- theta1.a <- theta2.a <- NULL sigma1 <- sigma1.a <- sigma2 <- sigma2.a <- nu1 <- nu1.a <- nu2 <- nu2.a <- NULL dof1 <- dof1.a <- dof2 <- dof2.a <- nCa1 <- nCa2 <- NULL cont1par <- VC$m1d cont2par <- c(VC$m2,VC$m2d) cont3par <- VC$m3 bin.link <- VC$bl if(VC$margins[2] == "LN" || VC$margins[3] == "LN") logLik <- -SemiParFit$fit$l.ln else logLik <- -SemiParFit$fit$l pVbres <- postVb(SemiParFit, VC) He <- pVbres$He Vb.t <- pVbres$Vb.t Vb <- pVbres$Vb HeSh <- pVbres$HeSh F <- pVbres$F F1 <- pVbres$F1 R <- pVbres$R Ve <- pVbres$Ve t.edf <- pVbres$t.edf SemiParFit <- pVbres$SemiParFit VC1 <- list(BivD = VC$BivD1, BivD2 = NULL) VC2 <- list(BivD = VC$BivD2, BivD2 = NULL) SemiParFit$fit$eta2 <- VC$X2s %*% SemiParFit$fit$argument[(VC$X1.d2 + 1):(VC$X1.d2 + VC$X2.d2)] SemiParFit$fit$eta3 <- VC$X3s %*% SemiParFit$fit$argument[(VC$X1.d2 + VC$X2.d2 + 1):(VC$X1.d2 + VC$X2.d2 + VC$X3.d2)] if( VC$margins[2] %in% c(cont2par, cont3par) && VC$margins[3] %in% c(cont2par, cont3par) ){ sigma1 <- esp.tr(VC$X4s%*%SemiParFit$fit$argument[(VC$X1.d2 + VC$X2.d2 + VC$X3.d2 + 1):(VC$X1.d2 + VC$X2.d2 + VC$X3.d2 + VC$X4.d2)], VC$margins[2])$vrb sigma1.a <- mean(sigma1) sigma2 <- esp.tr(VC$X5s%*%SemiParFit$fit$argument[(VC$X1.d2 + VC$X2.d2 + VC$X3.d2 + VC$X4.d2 + 1):(VC$X1.d2 + VC$X2.d2 + VC$X3.d2 + VC$X4.d2 + VC$X5.d2)], VC$margins[3])$vrb sigma2.a <- mean(sigma2) } if(VC$margins[2] %in% cont3par && VC$margins[3] %in% cont3par){ nu1 <- enu.tr(VC$X6s%*%SemiParFit$fit$argument[(VC$X1.d2 + VC$X2.d2 + VC$X3.d2 + VC$X4.d2 + VC$X5.d2 + 1):(VC$X1.d2 + VC$X2.d2 + VC$X3.d2 + VC$X4.d2 + VC$X5.d2 + VC$X6.d2)], VC$margins[2])$vrb nu1.a <- mean(nu1) nu2 <- enu.tr(VC$X7s%*%SemiParFit$fit$argument[(VC$X1.d2 + VC$X2.d2 + VC$X3.d2 + VC$X4.d2 + VC$X5.d2 + VC$X6.d2 + 1):(VC$X1.d2 + VC$X2.d2 + VC$X3.d2 + VC$X4.d2 + VC$X5.d2 + VC$X6.d2 + VC$X7.d2)], VC$margins[3])$vrb nu2.a <- mean(nu2) } if( VC$margins[2] %in% c(bin.link, cont1par) && VC$margins[3] %in% c(bin.link, cont1par) ){ teta1 <- teta.tr(VC1, VC$X4s%*%SemiParFit$fit$argument[(VC$X1.d2 + VC$X2.d2 + VC$X3.d2 + 1):(VC$X1.d2 + VC$X2.d2 + VC$X3.d2 + VC$X4.d2)])$teta teta2 <- teta.tr(VC2, VC$X5s%*%SemiParFit$fit$argument[(VC$X1.d2 + VC$X2.d2 + VC$X3.d2 + VC$X4.d2 + 1):(VC$X1.d2 + VC$X2.d2 + VC$X3.d2 + VC$X4.d2 + VC$X5.d2)])$teta ass.msR1 <- ass.ms(VC$BivD1, VC$nCa1, teta1) ass.msR2 <- ass.ms(VC$BivD2, VC$nCa2, teta2) } if( VC$margins[2] %in% c(cont2par) && VC$margins[3] %in% c(cont2par) ){ teta1 <- teta.tr(VC1, VC$X6s%*%SemiParFit$fit$argument[(VC$X1.d2 + VC$X2.d2 + VC$X3.d2 + VC$X4.d2 + VC$X5.d2 + 1):(VC$X1.d2 + VC$X2.d2 + VC$X3.d2 + VC$X4.d2 + VC$X5.d2 + VC$X6.d2)])$teta teta2 <- teta.tr(VC2, VC$X7s%*%SemiParFit$fit$argument[(VC$X1.d2 + VC$X2.d2 + VC$X3.d2 + VC$X4.d2 + VC$X5.d2 + VC$X6.d2 + 1):(VC$X1.d2 + VC$X2.d2 + VC$X3.d2 + VC$X4.d2 + VC$X5.d2 + VC$X6.d2 + VC$X7.d2)])$teta ass.msR1 <- ass.ms(VC$BivD1, VC$nCa1, teta1) ass.msR2 <- ass.ms(VC$BivD2, VC$nCa2, teta2) } if( VC$margins[2] %in% c(cont3par) && VC$margins[3] %in% c(cont3par) ){ teta1 <- teta.tr(VC1, VC$X8s%*%SemiParFit$fit$argument[(VC$X1.d2 + VC$X2.d2 + VC$X3.d2 + VC$X4.d2 + VC$X5.d2 + VC$X6.d2 + VC$X7.d2 + 1):(VC$X1.d2 + VC$X2.d2 + VC$X3.d2 + VC$X4.d2 + VC$X5.d2 + VC$X6.d2 + VC$X7.d2 + VC$X8.d2)])$teta teta2 <- teta.tr(VC2, VC$X9s%*%SemiParFit$fit$argument[(VC$X1.d2 + VC$X2.d2 + VC$X3.d2 + VC$X4.d2 + VC$X5.d2 + VC$X6.d2 + VC$X7.d2 + VC$X8.d2 + 1):(VC$X1.d2 + VC$X2.d2 + VC$X3.d2 + VC$X4.d2 + VC$X5.d2 + VC$X6.d2 + VC$X7.d2 + VC$X8.d2 + VC$X9.d2)])$teta ass.msR1 <- ass.ms(VC$BivD1, VC$nCa1, teta1) ass.msR2 <- ass.ms(VC$BivD2, VC$nCa2, teta2) } theta1 <- ass.msR1$theta theta1.a <- ass.msR1$theta.a tau1 <- ass.msR1$tau tau1.a <- ass.msR1$tau.a theta2 <- ass.msR2$theta theta2.a <- ass.msR2$theta.a tau2 <- ass.msR2$tau tau2.a <- ass.msR2$tau.a if(VC$gc.l == TRUE) gc() edf.loopR <- edf.loop(VC, F, F1, GAM) edf <- edf.loopR$edf edf1 <- edf.loopR$edf1 sp <- SemiParFit$sp list(SemiParFit = SemiParFit, He = He, logLik = logLik, Vb = Vb, HeSh = HeSh, F = F, F1 = F1, t.edf = t.edf, edf = edf, Vb.t = Vb.t, edf11 = edf1, edf1 = edf[[1]], edf2 = edf[[2]], edf3 = edf[[3]], edf4 = edf[[4]], edf5 = edf[[5]], edf6 = edf[[6]], edf7 = edf[[7]], edf8 = edf[[8]], edf9 = edf[[9]], edf1.1 = edf1[[1]], edf1.2 = edf1[[2]], edf1.3 = edf1[[3]], edf1.4 = edf1[[4]], edf1.5 = edf1[[5]], edf1.6 = edf1[[6]], edf1.7 = edf1[[7]], edf1.8 = edf1[[8]], edf1.9 = edf1[[9]], theta1 = theta1, theta1.a = theta1.a, theta2 = theta2, theta2.a = theta2.a, sigma2 = sigma2, sigma2.a = sigma2.a, sigma1 = sigma1, sigma1.a = sigma1.a, nu1 = nu1, nu1.a = nu1.a, nu2 = nu2, nu2.a = nu2.a, tau1 = tau1, tau1.a= tau1.a, tau2 = tau2, tau2.a= tau2.a, sp = sp, R = R, Ve = Ve, dof1.a = VC$dof1, dof1 = VC$dof1, dof2.a = VC$dof2, dof2 = VC$dof2, nCa1 = nCa1, nCa2 = nCa2) }
NULL .codebuild$batch_delete_builds_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(ids = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$batch_delete_builds_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(buildsDeleted = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list")), buildsNotDeleted = structure(list(structure(list(id = structure(logical(0), tags = list(type = "string")), statusCode = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$batch_get_build_batches_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(ids = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$batch_get_build_batches_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(buildBatches = structure(list(structure(list(id = structure(logical(0), tags = list(type = "string")), arn = structure(logical(0), tags = list(type = "string")), startTime = structure(logical(0), tags = list(type = "timestamp")), endTime = structure(logical(0), tags = list(type = "timestamp")), currentPhase = structure(logical(0), tags = list(type = "string")), buildBatchStatus = structure(logical(0), tags = list(type = "string")), sourceVersion = structure(logical(0), tags = list(type = "string")), resolvedSourceVersion = structure(logical(0), tags = list(type = "string")), projectName = structure(logical(0), tags = list(type = "string")), phases = structure(list(structure(list(phaseType = structure(logical(0), tags = list(type = "string")), phaseStatus = structure(logical(0), tags = list(type = "string")), startTime = structure(logical(0), tags = list(type = "timestamp")), endTime = structure(logical(0), tags = list(type = "timestamp")), durationInSeconds = structure(logical(0), tags = list(type = "long")), contexts = structure(list(structure(list(statusCode = structure(logical(0), tags = list(type = "string")), message = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure"))), tags = list(type = "list")), source = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), gitCloneDepth = structure(logical(0), tags = list(type = "integer")), gitSubmodulesConfig = structure(list(fetchSubmodules = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure")), buildspec = structure(logical(0), tags = list(type = "string")), auth = structure(list(type = structure(logical(0), tags = list(type = "string")), resource = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), reportBuildStatus = structure(logical(0), tags = list(type = "boolean")), buildStatusConfig = structure(list(context = structure(logical(0), tags = list(type = "string")), targetUrl = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), insecureSsl = structure(logical(0), tags = list(type = "boolean")), sourceIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), secondarySources = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), gitCloneDepth = structure(logical(0), tags = list(type = "integer")), gitSubmodulesConfig = structure(list(fetchSubmodules = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure")), buildspec = structure(logical(0), tags = list(type = "string")), auth = structure(list(type = structure(logical(0), tags = list(type = "string")), resource = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), reportBuildStatus = structure(logical(0), tags = list(type = "boolean")), buildStatusConfig = structure(list(context = structure(logical(0), tags = list(type = "string")), targetUrl = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), insecureSsl = structure(logical(0), tags = list(type = "boolean")), sourceIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), secondarySourceVersions = structure(list(structure(list(sourceIdentifier = structure(logical(0), tags = list(type = "string")), sourceVersion = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), artifacts = structure(list(location = structure(logical(0), tags = list(type = "string")), sha256sum = structure(logical(0), tags = list(type = "string")), md5sum = structure(logical(0), tags = list(type = "string")), overrideArtifactName = structure(logical(0), tags = list(type = "boolean")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean")), artifactIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), secondaryArtifacts = structure(list(structure(list(location = structure(logical(0), tags = list(type = "string")), sha256sum = structure(logical(0), tags = list(type = "string")), md5sum = structure(logical(0), tags = list(type = "string")), overrideArtifactName = structure(logical(0), tags = list(type = "boolean")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean")), artifactIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), cache = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), modes = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")), environment = structure(list(type = structure(logical(0), tags = list(type = "string")), image = structure(logical(0), tags = list(type = "string")), computeType = structure(logical(0), tags = list(type = "string")), environmentVariables = structure(list(structure(list(name = structure(logical(0), tags = list(type = "string")), value = structure(logical(0), tags = list(type = "string")), type = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), privilegedMode = structure(logical(0), tags = list(type = "boolean")), certificate = structure(logical(0), tags = list(type = "string")), registryCredential = structure(list(credential = structure(logical(0), tags = list(type = "string")), credentialProvider = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), imagePullCredentialsType = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), serviceRole = structure(logical(0), tags = list(type = "string")), logConfig = structure(list(cloudWatchLogs = structure(list(status = structure(logical(0), tags = list(type = "string")), groupName = structure(logical(0), tags = list(type = "string")), streamName = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), s3Logs = structure(list(status = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure"))), tags = list(type = "structure")), buildTimeoutInMinutes = structure(logical(0), tags = list(type = "integer")), queuedTimeoutInMinutes = structure(logical(0), tags = list(type = "integer")), complete = structure(logical(0), tags = list(type = "boolean")), initiator = structure(logical(0), tags = list(type = "string")), vpcConfig = structure(list(vpcId = structure(logical(0), tags = list(type = "string")), subnets = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list")), securityGroupIds = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")), encryptionKey = structure(logical(0), tags = list(type = "string")), buildBatchNumber = structure(logical(0), tags = list(type = "long")), fileSystemLocations = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), mountPoint = structure(logical(0), tags = list(type = "string")), identifier = structure(logical(0), tags = list(type = "string")), mountOptions = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), buildBatchConfig = structure(list(serviceRole = structure(logical(0), tags = list(type = "string")), combineArtifacts = structure(logical(0), tags = list(type = "boolean")), restrictions = structure(list(maximumBuildsAllowed = structure(logical(0), tags = list(type = "integer")), computeTypesAllowed = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")), timeoutInMins = structure(logical(0), tags = list(type = "integer"))), tags = list(type = "structure")), buildGroups = structure(list(structure(list(identifier = structure(logical(0), tags = list(type = "string")), dependsOn = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list")), ignoreFailure = structure(logical(0), tags = list(type = "boolean")), currentBuildSummary = structure(list(arn = structure(logical(0), tags = list(type = "string")), requestedOn = structure(logical(0), tags = list(type = "timestamp")), buildStatus = structure(logical(0), tags = list(type = "string")), primaryArtifact = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), identifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), secondaryArtifacts = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), identifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure")), priorBuildSummaryList = structure(list(structure(list(arn = structure(logical(0), tags = list(type = "string")), requestedOn = structure(logical(0), tags = list(type = "timestamp")), buildStatus = structure(logical(0), tags = list(type = "string")), primaryArtifact = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), identifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), secondaryArtifacts = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), identifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure"))), tags = list(type = "list")), buildBatchesNotFound = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$batch_get_builds_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(ids = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$batch_get_builds_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(builds = structure(list(structure(list(id = structure(logical(0), tags = list(type = "string")), arn = structure(logical(0), tags = list(type = "string")), buildNumber = structure(logical(0), tags = list(type = "long")), startTime = structure(logical(0), tags = list(type = "timestamp")), endTime = structure(logical(0), tags = list(type = "timestamp")), currentPhase = structure(logical(0), tags = list(type = "string")), buildStatus = structure(logical(0), tags = list(type = "string")), sourceVersion = structure(logical(0), tags = list(type = "string")), resolvedSourceVersion = structure(logical(0), tags = list(type = "string")), projectName = structure(logical(0), tags = list(type = "string")), phases = structure(list(structure(list(phaseType = structure(logical(0), tags = list(type = "string")), phaseStatus = structure(logical(0), tags = list(type = "string")), startTime = structure(logical(0), tags = list(type = "timestamp")), endTime = structure(logical(0), tags = list(type = "timestamp")), durationInSeconds = structure(logical(0), tags = list(type = "long")), contexts = structure(list(structure(list(statusCode = structure(logical(0), tags = list(type = "string")), message = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure"))), tags = list(type = "list")), source = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), gitCloneDepth = structure(logical(0), tags = list(type = "integer")), gitSubmodulesConfig = structure(list(fetchSubmodules = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure")), buildspec = structure(logical(0), tags = list(type = "string")), auth = structure(list(type = structure(logical(0), tags = list(type = "string")), resource = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), reportBuildStatus = structure(logical(0), tags = list(type = "boolean")), buildStatusConfig = structure(list(context = structure(logical(0), tags = list(type = "string")), targetUrl = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), insecureSsl = structure(logical(0), tags = list(type = "boolean")), sourceIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), secondarySources = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), gitCloneDepth = structure(logical(0), tags = list(type = "integer")), gitSubmodulesConfig = structure(list(fetchSubmodules = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure")), buildspec = structure(logical(0), tags = list(type = "string")), auth = structure(list(type = structure(logical(0), tags = list(type = "string")), resource = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), reportBuildStatus = structure(logical(0), tags = list(type = "boolean")), buildStatusConfig = structure(list(context = structure(logical(0), tags = list(type = "string")), targetUrl = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), insecureSsl = structure(logical(0), tags = list(type = "boolean")), sourceIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), secondarySourceVersions = structure(list(structure(list(sourceIdentifier = structure(logical(0), tags = list(type = "string")), sourceVersion = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), artifacts = structure(list(location = structure(logical(0), tags = list(type = "string")), sha256sum = structure(logical(0), tags = list(type = "string")), md5sum = structure(logical(0), tags = list(type = "string")), overrideArtifactName = structure(logical(0), tags = list(type = "boolean")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean")), artifactIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), secondaryArtifacts = structure(list(structure(list(location = structure(logical(0), tags = list(type = "string")), sha256sum = structure(logical(0), tags = list(type = "string")), md5sum = structure(logical(0), tags = list(type = "string")), overrideArtifactName = structure(logical(0), tags = list(type = "boolean")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean")), artifactIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), cache = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), modes = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")), environment = structure(list(type = structure(logical(0), tags = list(type = "string")), image = structure(logical(0), tags = list(type = "string")), computeType = structure(logical(0), tags = list(type = "string")), environmentVariables = structure(list(structure(list(name = structure(logical(0), tags = list(type = "string")), value = structure(logical(0), tags = list(type = "string")), type = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), privilegedMode = structure(logical(0), tags = list(type = "boolean")), certificate = structure(logical(0), tags = list(type = "string")), registryCredential = structure(list(credential = structure(logical(0), tags = list(type = "string")), credentialProvider = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), imagePullCredentialsType = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), serviceRole = structure(logical(0), tags = list(type = "string")), logs = structure(list(groupName = structure(logical(0), tags = list(type = "string")), streamName = structure(logical(0), tags = list(type = "string")), deepLink = structure(logical(0), tags = list(type = "string")), s3DeepLink = structure(logical(0), tags = list(type = "string")), cloudWatchLogsArn = structure(logical(0), tags = list(type = "string")), s3LogsArn = structure(logical(0), tags = list(type = "string")), cloudWatchLogs = structure(list(status = structure(logical(0), tags = list(type = "string")), groupName = structure(logical(0), tags = list(type = "string")), streamName = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), s3Logs = structure(list(status = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure"))), tags = list(type = "structure")), timeoutInMinutes = structure(logical(0), tags = list(type = "integer")), queuedTimeoutInMinutes = structure(logical(0), tags = list(type = "integer")), buildComplete = structure(logical(0), tags = list(type = "boolean")), initiator = structure(logical(0), tags = list(type = "string")), vpcConfig = structure(list(vpcId = structure(logical(0), tags = list(type = "string")), subnets = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list")), securityGroupIds = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")), networkInterface = structure(list(subnetId = structure(logical(0), tags = list(type = "string")), networkInterfaceId = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), encryptionKey = structure(logical(0), tags = list(type = "string")), exportedEnvironmentVariables = structure(list(structure(list(name = structure(logical(0), tags = list(type = "string")), value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), reportArns = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list")), fileSystemLocations = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), mountPoint = structure(logical(0), tags = list(type = "string")), identifier = structure(logical(0), tags = list(type = "string")), mountOptions = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), debugSession = structure(list(sessionEnabled = structure(logical(0), tags = list(type = "boolean")), sessionTarget = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), buildBatchArn = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), buildsNotFound = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$batch_get_projects_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(names = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$batch_get_projects_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(projects = structure(list(structure(list(name = structure(logical(0), tags = list(type = "string")), arn = structure(logical(0), tags = list(type = "string")), description = structure(logical(0), tags = list(type = "string")), source = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), gitCloneDepth = structure(logical(0), tags = list(type = "integer")), gitSubmodulesConfig = structure(list(fetchSubmodules = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure")), buildspec = structure(logical(0), tags = list(type = "string")), auth = structure(list(type = structure(logical(0), tags = list(type = "string")), resource = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), reportBuildStatus = structure(logical(0), tags = list(type = "boolean")), buildStatusConfig = structure(list(context = structure(logical(0), tags = list(type = "string")), targetUrl = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), insecureSsl = structure(logical(0), tags = list(type = "boolean")), sourceIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), secondarySources = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), gitCloneDepth = structure(logical(0), tags = list(type = "integer")), gitSubmodulesConfig = structure(list(fetchSubmodules = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure")), buildspec = structure(logical(0), tags = list(type = "string")), auth = structure(list(type = structure(logical(0), tags = list(type = "string")), resource = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), reportBuildStatus = structure(logical(0), tags = list(type = "boolean")), buildStatusConfig = structure(list(context = structure(logical(0), tags = list(type = "string")), targetUrl = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), insecureSsl = structure(logical(0), tags = list(type = "boolean")), sourceIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), sourceVersion = structure(logical(0), tags = list(type = "string")), secondarySourceVersions = structure(list(structure(list(sourceIdentifier = structure(logical(0), tags = list(type = "string")), sourceVersion = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), artifacts = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), path = structure(logical(0), tags = list(type = "string")), namespaceType = structure(logical(0), tags = list(type = "string")), name = structure(logical(0), tags = list(type = "string")), packaging = structure(logical(0), tags = list(type = "string")), overrideArtifactName = structure(logical(0), tags = list(type = "boolean")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean")), artifactIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), secondaryArtifacts = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), path = structure(logical(0), tags = list(type = "string")), namespaceType = structure(logical(0), tags = list(type = "string")), name = structure(logical(0), tags = list(type = "string")), packaging = structure(logical(0), tags = list(type = "string")), overrideArtifactName = structure(logical(0), tags = list(type = "boolean")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean")), artifactIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), cache = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), modes = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")), environment = structure(list(type = structure(logical(0), tags = list(type = "string")), image = structure(logical(0), tags = list(type = "string")), computeType = structure(logical(0), tags = list(type = "string")), environmentVariables = structure(list(structure(list(name = structure(logical(0), tags = list(type = "string")), value = structure(logical(0), tags = list(type = "string")), type = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), privilegedMode = structure(logical(0), tags = list(type = "boolean")), certificate = structure(logical(0), tags = list(type = "string")), registryCredential = structure(list(credential = structure(logical(0), tags = list(type = "string")), credentialProvider = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), imagePullCredentialsType = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), serviceRole = structure(logical(0), tags = list(type = "string")), timeoutInMinutes = structure(logical(0), tags = list(type = "integer")), queuedTimeoutInMinutes = structure(logical(0), tags = list(type = "integer")), encryptionKey = structure(logical(0), tags = list(type = "string")), tags = structure(list(structure(list(key = structure(logical(0), tags = list(type = "string")), value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), created = structure(logical(0), tags = list(type = "timestamp")), lastModified = structure(logical(0), tags = list(type = "timestamp")), webhook = structure(list(url = structure(logical(0), tags = list(type = "string")), payloadUrl = structure(logical(0), tags = list(type = "string")), secret = structure(logical(0), tags = list(type = "string")), branchFilter = structure(logical(0), tags = list(type = "string")), filterGroups = structure(list(structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), pattern = structure(logical(0), tags = list(type = "string")), excludeMatchedPattern = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "list")), buildType = structure(logical(0), tags = list(type = "string")), lastModifiedSecret = structure(logical(0), tags = list(type = "timestamp"))), tags = list(type = "structure")), vpcConfig = structure(list(vpcId = structure(logical(0), tags = list(type = "string")), subnets = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list")), securityGroupIds = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")), badge = structure(list(badgeEnabled = structure(logical(0), tags = list(type = "boolean")), badgeRequestUrl = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), logsConfig = structure(list(cloudWatchLogs = structure(list(status = structure(logical(0), tags = list(type = "string")), groupName = structure(logical(0), tags = list(type = "string")), streamName = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), s3Logs = structure(list(status = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure"))), tags = list(type = "structure")), fileSystemLocations = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), mountPoint = structure(logical(0), tags = list(type = "string")), identifier = structure(logical(0), tags = list(type = "string")), mountOptions = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), buildBatchConfig = structure(list(serviceRole = structure(logical(0), tags = list(type = "string")), combineArtifacts = structure(logical(0), tags = list(type = "boolean")), restrictions = structure(list(maximumBuildsAllowed = structure(logical(0), tags = list(type = "integer")), computeTypesAllowed = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")), timeoutInMins = structure(logical(0), tags = list(type = "integer"))), tags = list(type = "structure"))), tags = list(type = "structure"))), tags = list(type = "list")), projectsNotFound = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$batch_get_report_groups_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(reportGroupArns = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$batch_get_report_groups_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(reportGroups = structure(list(structure(list(arn = structure(logical(0), tags = list(type = "string")), name = structure(logical(0), tags = list(type = "string")), type = structure(logical(0), tags = list(type = "string")), exportConfig = structure(list(exportConfigType = structure(logical(0), tags = list(type = "string")), s3Destination = structure(list(bucket = structure(logical(0), tags = list(type = "string")), path = structure(logical(0), tags = list(type = "string")), packaging = structure(logical(0), tags = list(type = "string")), encryptionKey = structure(logical(0), tags = list(type = "string")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure"))), tags = list(type = "structure")), created = structure(logical(0), tags = list(type = "timestamp")), lastModified = structure(logical(0), tags = list(type = "timestamp")), tags = structure(list(structure(list(key = structure(logical(0), tags = list(type = "string")), value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), status = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), reportGroupsNotFound = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$batch_get_reports_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(reportArns = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$batch_get_reports_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(reports = structure(list(structure(list(arn = structure(logical(0), tags = list(type = "string")), type = structure(logical(0), tags = list(type = "string")), name = structure(logical(0), tags = list(type = "string")), reportGroupArn = structure(logical(0), tags = list(type = "string")), executionId = structure(logical(0), tags = list(type = "string")), status = structure(logical(0), tags = list(type = "string")), created = structure(logical(0), tags = list(type = "timestamp")), expired = structure(logical(0), tags = list(type = "timestamp")), exportConfig = structure(list(exportConfigType = structure(logical(0), tags = list(type = "string")), s3Destination = structure(list(bucket = structure(logical(0), tags = list(type = "string")), path = structure(logical(0), tags = list(type = "string")), packaging = structure(logical(0), tags = list(type = "string")), encryptionKey = structure(logical(0), tags = list(type = "string")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure"))), tags = list(type = "structure")), truncated = structure(logical(0), tags = list(type = "boolean")), testSummary = structure(list(total = structure(logical(0), tags = list(type = "integer")), statusCounts = structure(list(structure(logical(0), tags = list(type = "integer"))), tags = list(type = "map")), durationInNanoSeconds = structure(logical(0), tags = list(type = "long"))), tags = list(type = "structure")), codeCoverageSummary = structure(list(lineCoveragePercentage = structure(logical(0), tags = list(type = "double")), linesCovered = structure(logical(0), tags = list(type = "integer")), linesMissed = structure(logical(0), tags = list(type = "integer")), branchCoveragePercentage = structure(logical(0), tags = list(type = "double")), branchesCovered = structure(logical(0), tags = list(type = "integer")), branchesMissed = structure(logical(0), tags = list(type = "integer"))), tags = list(type = "structure"))), tags = list(type = "structure"))), tags = list(type = "list")), reportsNotFound = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$create_project_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(name = structure(logical(0), tags = list(type = "string")), description = structure(logical(0), tags = list(type = "string")), source = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), gitCloneDepth = structure(logical(0), tags = list(type = "integer")), gitSubmodulesConfig = structure(list(fetchSubmodules = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure")), buildspec = structure(logical(0), tags = list(type = "string")), auth = structure(list(type = structure(logical(0), tags = list(type = "string")), resource = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), reportBuildStatus = structure(logical(0), tags = list(type = "boolean")), buildStatusConfig = structure(list(context = structure(logical(0), tags = list(type = "string")), targetUrl = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), insecureSsl = structure(logical(0), tags = list(type = "boolean")), sourceIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), secondarySources = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), gitCloneDepth = structure(logical(0), tags = list(type = "integer")), gitSubmodulesConfig = structure(list(fetchSubmodules = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure")), buildspec = structure(logical(0), tags = list(type = "string")), auth = structure(list(type = structure(logical(0), tags = list(type = "string")), resource = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), reportBuildStatus = structure(logical(0), tags = list(type = "boolean")), buildStatusConfig = structure(list(context = structure(logical(0), tags = list(type = "string")), targetUrl = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), insecureSsl = structure(logical(0), tags = list(type = "boolean")), sourceIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), sourceVersion = structure(logical(0), tags = list(type = "string")), secondarySourceVersions = structure(list(structure(list(sourceIdentifier = structure(logical(0), tags = list(type = "string")), sourceVersion = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), artifacts = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), path = structure(logical(0), tags = list(type = "string")), namespaceType = structure(logical(0), tags = list(type = "string")), name = structure(logical(0), tags = list(type = "string")), packaging = structure(logical(0), tags = list(type = "string")), overrideArtifactName = structure(logical(0), tags = list(type = "boolean")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean")), artifactIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), secondaryArtifacts = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), path = structure(logical(0), tags = list(type = "string")), namespaceType = structure(logical(0), tags = list(type = "string")), name = structure(logical(0), tags = list(type = "string")), packaging = structure(logical(0), tags = list(type = "string")), overrideArtifactName = structure(logical(0), tags = list(type = "boolean")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean")), artifactIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), cache = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), modes = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")), environment = structure(list(type = structure(logical(0), tags = list(type = "string")), image = structure(logical(0), tags = list(type = "string")), computeType = structure(logical(0), tags = list(type = "string")), environmentVariables = structure(list(structure(list(name = structure(logical(0), tags = list(type = "string")), value = structure(logical(0), tags = list(type = "string")), type = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), privilegedMode = structure(logical(0), tags = list(type = "boolean")), certificate = structure(logical(0), tags = list(type = "string")), registryCredential = structure(list(credential = structure(logical(0), tags = list(type = "string")), credentialProvider = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), imagePullCredentialsType = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), serviceRole = structure(logical(0), tags = list(type = "string")), timeoutInMinutes = structure(logical(0), tags = list(type = "integer")), queuedTimeoutInMinutes = structure(logical(0), tags = list(type = "integer")), encryptionKey = structure(logical(0), tags = list(type = "string")), tags = structure(list(structure(list(key = structure(logical(0), tags = list(type = "string")), value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), vpcConfig = structure(list(vpcId = structure(logical(0), tags = list(type = "string")), subnets = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list")), securityGroupIds = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")), badgeEnabled = structure(logical(0), tags = list(type = "boolean")), logsConfig = structure(list(cloudWatchLogs = structure(list(status = structure(logical(0), tags = list(type = "string")), groupName = structure(logical(0), tags = list(type = "string")), streamName = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), s3Logs = structure(list(status = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure"))), tags = list(type = "structure")), fileSystemLocations = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), mountPoint = structure(logical(0), tags = list(type = "string")), identifier = structure(logical(0), tags = list(type = "string")), mountOptions = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), buildBatchConfig = structure(list(serviceRole = structure(logical(0), tags = list(type = "string")), combineArtifacts = structure(logical(0), tags = list(type = "boolean")), restrictions = structure(list(maximumBuildsAllowed = structure(logical(0), tags = list(type = "integer")), computeTypesAllowed = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")), timeoutInMins = structure(logical(0), tags = list(type = "integer"))), tags = list(type = "structure"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$create_project_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(project = structure(list(name = structure(logical(0), tags = list(type = "string")), arn = structure(logical(0), tags = list(type = "string")), description = structure(logical(0), tags = list(type = "string")), source = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), gitCloneDepth = structure(logical(0), tags = list(type = "integer")), gitSubmodulesConfig = structure(list(fetchSubmodules = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure")), buildspec = structure(logical(0), tags = list(type = "string")), auth = structure(list(type = structure(logical(0), tags = list(type = "string")), resource = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), reportBuildStatus = structure(logical(0), tags = list(type = "boolean")), buildStatusConfig = structure(list(context = structure(logical(0), tags = list(type = "string")), targetUrl = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), insecureSsl = structure(logical(0), tags = list(type = "boolean")), sourceIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), secondarySources = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), gitCloneDepth = structure(logical(0), tags = list(type = "integer")), gitSubmodulesConfig = structure(list(fetchSubmodules = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure")), buildspec = structure(logical(0), tags = list(type = "string")), auth = structure(list(type = structure(logical(0), tags = list(type = "string")), resource = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), reportBuildStatus = structure(logical(0), tags = list(type = "boolean")), buildStatusConfig = structure(list(context = structure(logical(0), tags = list(type = "string")), targetUrl = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), insecureSsl = structure(logical(0), tags = list(type = "boolean")), sourceIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), sourceVersion = structure(logical(0), tags = list(type = "string")), secondarySourceVersions = structure(list(structure(list(sourceIdentifier = structure(logical(0), tags = list(type = "string")), sourceVersion = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), artifacts = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), path = structure(logical(0), tags = list(type = "string")), namespaceType = structure(logical(0), tags = list(type = "string")), name = structure(logical(0), tags = list(type = "string")), packaging = structure(logical(0), tags = list(type = "string")), overrideArtifactName = structure(logical(0), tags = list(type = "boolean")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean")), artifactIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), secondaryArtifacts = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), path = structure(logical(0), tags = list(type = "string")), namespaceType = structure(logical(0), tags = list(type = "string")), name = structure(logical(0), tags = list(type = "string")), packaging = structure(logical(0), tags = list(type = "string")), overrideArtifactName = structure(logical(0), tags = list(type = "boolean")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean")), artifactIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), cache = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), modes = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")), environment = structure(list(type = structure(logical(0), tags = list(type = "string")), image = structure(logical(0), tags = list(type = "string")), computeType = structure(logical(0), tags = list(type = "string")), environmentVariables = structure(list(structure(list(name = structure(logical(0), tags = list(type = "string")), value = structure(logical(0), tags = list(type = "string")), type = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), privilegedMode = structure(logical(0), tags = list(type = "boolean")), certificate = structure(logical(0), tags = list(type = "string")), registryCredential = structure(list(credential = structure(logical(0), tags = list(type = "string")), credentialProvider = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), imagePullCredentialsType = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), serviceRole = structure(logical(0), tags = list(type = "string")), timeoutInMinutes = structure(logical(0), tags = list(type = "integer")), queuedTimeoutInMinutes = structure(logical(0), tags = list(type = "integer")), encryptionKey = structure(logical(0), tags = list(type = "string")), tags = structure(list(structure(list(key = structure(logical(0), tags = list(type = "string")), value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), created = structure(logical(0), tags = list(type = "timestamp")), lastModified = structure(logical(0), tags = list(type = "timestamp")), webhook = structure(list(url = structure(logical(0), tags = list(type = "string")), payloadUrl = structure(logical(0), tags = list(type = "string")), secret = structure(logical(0), tags = list(type = "string")), branchFilter = structure(logical(0), tags = list(type = "string")), filterGroups = structure(list(structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), pattern = structure(logical(0), tags = list(type = "string")), excludeMatchedPattern = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "list")), buildType = structure(logical(0), tags = list(type = "string")), lastModifiedSecret = structure(logical(0), tags = list(type = "timestamp"))), tags = list(type = "structure")), vpcConfig = structure(list(vpcId = structure(logical(0), tags = list(type = "string")), subnets = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list")), securityGroupIds = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")), badge = structure(list(badgeEnabled = structure(logical(0), tags = list(type = "boolean")), badgeRequestUrl = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), logsConfig = structure(list(cloudWatchLogs = structure(list(status = structure(logical(0), tags = list(type = "string")), groupName = structure(logical(0), tags = list(type = "string")), streamName = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), s3Logs = structure(list(status = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure"))), tags = list(type = "structure")), fileSystemLocations = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), mountPoint = structure(logical(0), tags = list(type = "string")), identifier = structure(logical(0), tags = list(type = "string")), mountOptions = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), buildBatchConfig = structure(list(serviceRole = structure(logical(0), tags = list(type = "string")), combineArtifacts = structure(logical(0), tags = list(type = "boolean")), restrictions = structure(list(maximumBuildsAllowed = structure(logical(0), tags = list(type = "integer")), computeTypesAllowed = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")), timeoutInMins = structure(logical(0), tags = list(type = "integer"))), tags = list(type = "structure"))), tags = list(type = "structure"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$create_report_group_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(name = structure(logical(0), tags = list(type = "string")), type = structure(logical(0), tags = list(type = "string")), exportConfig = structure(list(exportConfigType = structure(logical(0), tags = list(type = "string")), s3Destination = structure(list(bucket = structure(logical(0), tags = list(type = "string")), path = structure(logical(0), tags = list(type = "string")), packaging = structure(logical(0), tags = list(type = "string")), encryptionKey = structure(logical(0), tags = list(type = "string")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure"))), tags = list(type = "structure")), tags = structure(list(structure(list(key = structure(logical(0), tags = list(type = "string")), value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$create_report_group_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(reportGroup = structure(list(arn = structure(logical(0), tags = list(type = "string")), name = structure(logical(0), tags = list(type = "string")), type = structure(logical(0), tags = list(type = "string")), exportConfig = structure(list(exportConfigType = structure(logical(0), tags = list(type = "string")), s3Destination = structure(list(bucket = structure(logical(0), tags = list(type = "string")), path = structure(logical(0), tags = list(type = "string")), packaging = structure(logical(0), tags = list(type = "string")), encryptionKey = structure(logical(0), tags = list(type = "string")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure"))), tags = list(type = "structure")), created = structure(logical(0), tags = list(type = "timestamp")), lastModified = structure(logical(0), tags = list(type = "timestamp")), tags = structure(list(structure(list(key = structure(logical(0), tags = list(type = "string")), value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), status = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$create_webhook_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(projectName = structure(logical(0), tags = list(type = "string")), branchFilter = structure(logical(0), tags = list(type = "string")), filterGroups = structure(list(structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), pattern = structure(logical(0), tags = list(type = "string")), excludeMatchedPattern = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "list")), buildType = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$create_webhook_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(webhook = structure(list(url = structure(logical(0), tags = list(type = "string")), payloadUrl = structure(logical(0), tags = list(type = "string")), secret = structure(logical(0), tags = list(type = "string")), branchFilter = structure(logical(0), tags = list(type = "string")), filterGroups = structure(list(structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), pattern = structure(logical(0), tags = list(type = "string")), excludeMatchedPattern = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "list")), buildType = structure(logical(0), tags = list(type = "string")), lastModifiedSecret = structure(logical(0), tags = list(type = "timestamp"))), tags = list(type = "structure"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$delete_build_batch_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(id = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$delete_build_batch_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(statusCode = structure(logical(0), tags = list(type = "string")), buildsDeleted = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list")), buildsNotDeleted = structure(list(structure(list(id = structure(logical(0), tags = list(type = "string")), statusCode = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$delete_project_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(name = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$delete_project_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$delete_report_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(arn = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$delete_report_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$delete_report_group_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(arn = structure(logical(0), tags = list(type = "string")), deleteReports = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$delete_report_group_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$delete_resource_policy_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(resourceArn = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$delete_resource_policy_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$delete_source_credentials_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(arn = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$delete_source_credentials_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(arn = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$delete_webhook_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(projectName = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$delete_webhook_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$describe_code_coverages_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(reportArn = structure(logical(0), tags = list(type = "string")), nextToken = structure(logical(0), tags = list(type = "string")), maxResults = structure(logical(0), tags = list(type = "integer")), sortOrder = structure(logical(0), tags = list(type = "string")), sortBy = structure(logical(0), tags = list(type = "string")), minLineCoveragePercentage = structure(logical(0), tags = list(type = "double")), maxLineCoveragePercentage = structure(logical(0), tags = list(type = "double"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$describe_code_coverages_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(nextToken = structure(logical(0), tags = list(type = "string")), codeCoverages = structure(list(structure(list(id = structure(logical(0), tags = list(type = "string")), reportARN = structure(logical(0), tags = list(type = "string")), filePath = structure(logical(0), tags = list(type = "string")), lineCoveragePercentage = structure(logical(0), tags = list(type = "double")), linesCovered = structure(logical(0), tags = list(type = "integer")), linesMissed = structure(logical(0), tags = list(type = "integer")), branchCoveragePercentage = structure(logical(0), tags = list(type = "double")), branchesCovered = structure(logical(0), tags = list(type = "integer")), branchesMissed = structure(logical(0), tags = list(type = "integer")), expired = structure(logical(0), tags = list(type = "timestamp"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$describe_test_cases_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(reportArn = structure(logical(0), tags = list(type = "string")), nextToken = structure(logical(0), tags = list(type = "string")), maxResults = structure(logical(0), tags = list(type = "integer")), filter = structure(list(status = structure(logical(0), tags = list(type = "string")), keyword = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$describe_test_cases_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(nextToken = structure(logical(0), tags = list(type = "string")), testCases = structure(list(structure(list(reportArn = structure(logical(0), tags = list(type = "string")), testRawDataPath = structure(logical(0), tags = list(type = "string")), prefix = structure(logical(0), tags = list(type = "string")), name = structure(logical(0), tags = list(type = "string")), status = structure(logical(0), tags = list(type = "string")), durationInNanoSeconds = structure(logical(0), tags = list(type = "long")), message = structure(logical(0), tags = list(type = "string")), expired = structure(logical(0), tags = list(type = "timestamp"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$get_report_group_trend_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(reportGroupArn = structure(logical(0), tags = list(type = "string")), numOfReports = structure(logical(0), tags = list(type = "integer")), trendField = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$get_report_group_trend_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(stats = structure(list(average = structure(logical(0), tags = list(type = "string")), max = structure(logical(0), tags = list(type = "string")), min = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), rawData = structure(list(structure(list(reportArn = structure(logical(0), tags = list(type = "string")), data = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$get_resource_policy_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(resourceArn = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$get_resource_policy_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(policy = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$import_source_credentials_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(username = structure(logical(0), tags = list(type = "string")), token = structure(logical(0), tags = list(type = "string", sensitive = TRUE)), serverType = structure(logical(0), tags = list(type = "string")), authType = structure(logical(0), tags = list(type = "string")), shouldOverwrite = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$import_source_credentials_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(arn = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$invalidate_project_cache_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(projectName = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$invalidate_project_cache_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$list_build_batches_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(filter = structure(list(status = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), maxResults = structure(logical(0), tags = list(type = "integer")), sortOrder = structure(logical(0), tags = list(type = "string")), nextToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$list_build_batches_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(ids = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list")), nextToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$list_build_batches_for_project_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(projectName = structure(logical(0), tags = list(type = "string")), filter = structure(list(status = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), maxResults = structure(logical(0), tags = list(type = "integer")), sortOrder = structure(logical(0), tags = list(type = "string")), nextToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$list_build_batches_for_project_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(ids = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list")), nextToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$list_builds_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(sortOrder = structure(logical(0), tags = list(type = "string")), nextToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$list_builds_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(ids = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list")), nextToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$list_builds_for_project_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(projectName = structure(logical(0), tags = list(type = "string")), sortOrder = structure(logical(0), tags = list(type = "string")), nextToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$list_builds_for_project_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(ids = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list")), nextToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$list_curated_environment_images_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$list_curated_environment_images_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(platforms = structure(list(structure(list(platform = structure(logical(0), tags = list(type = "string")), languages = structure(list(structure(list(language = structure(logical(0), tags = list(type = "string")), images = structure(list(structure(list(name = structure(logical(0), tags = list(type = "string")), description = structure(logical(0), tags = list(type = "string")), versions = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$list_projects_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(sortBy = structure(logical(0), tags = list(type = "string")), sortOrder = structure(logical(0), tags = list(type = "string")), nextToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$list_projects_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(nextToken = structure(logical(0), tags = list(type = "string")), projects = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$list_report_groups_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(sortOrder = structure(logical(0), tags = list(type = "string")), sortBy = structure(logical(0), tags = list(type = "string")), nextToken = structure(logical(0), tags = list(type = "string")), maxResults = structure(logical(0), tags = list(type = "integer"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$list_report_groups_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(nextToken = structure(logical(0), tags = list(type = "string")), reportGroups = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$list_reports_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(sortOrder = structure(logical(0), tags = list(type = "string")), nextToken = structure(logical(0), tags = list(type = "string")), maxResults = structure(logical(0), tags = list(type = "integer")), filter = structure(list(status = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$list_reports_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(nextToken = structure(logical(0), tags = list(type = "string")), reports = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$list_reports_for_report_group_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(reportGroupArn = structure(logical(0), tags = list(type = "string")), nextToken = structure(logical(0), tags = list(type = "string")), sortOrder = structure(logical(0), tags = list(type = "string")), maxResults = structure(logical(0), tags = list(type = "integer")), filter = structure(list(status = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$list_reports_for_report_group_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(nextToken = structure(logical(0), tags = list(type = "string")), reports = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$list_shared_projects_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(sortBy = structure(logical(0), tags = list(type = "string")), sortOrder = structure(logical(0), tags = list(type = "string")), maxResults = structure(logical(0), tags = list(type = "integer")), nextToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$list_shared_projects_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(nextToken = structure(logical(0), tags = list(type = "string")), projects = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$list_shared_report_groups_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(sortOrder = structure(logical(0), tags = list(type = "string")), sortBy = structure(logical(0), tags = list(type = "string")), nextToken = structure(logical(0), tags = list(type = "string")), maxResults = structure(logical(0), tags = list(type = "integer"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$list_shared_report_groups_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(nextToken = structure(logical(0), tags = list(type = "string")), reportGroups = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$list_source_credentials_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$list_source_credentials_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(sourceCredentialsInfos = structure(list(structure(list(arn = structure(logical(0), tags = list(type = "string")), serverType = structure(logical(0), tags = list(type = "string")), authType = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$put_resource_policy_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(policy = structure(logical(0), tags = list(type = "string")), resourceArn = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$put_resource_policy_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(resourceArn = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$retry_build_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(id = structure(logical(0), tags = list(type = "string")), idempotencyToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$retry_build_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(build = structure(list(id = structure(logical(0), tags = list(type = "string")), arn = structure(logical(0), tags = list(type = "string")), buildNumber = structure(logical(0), tags = list(type = "long")), startTime = structure(logical(0), tags = list(type = "timestamp")), endTime = structure(logical(0), tags = list(type = "timestamp")), currentPhase = structure(logical(0), tags = list(type = "string")), buildStatus = structure(logical(0), tags = list(type = "string")), sourceVersion = structure(logical(0), tags = list(type = "string")), resolvedSourceVersion = structure(logical(0), tags = list(type = "string")), projectName = structure(logical(0), tags = list(type = "string")), phases = structure(list(structure(list(phaseType = structure(logical(0), tags = list(type = "string")), phaseStatus = structure(logical(0), tags = list(type = "string")), startTime = structure(logical(0), tags = list(type = "timestamp")), endTime = structure(logical(0), tags = list(type = "timestamp")), durationInSeconds = structure(logical(0), tags = list(type = "long")), contexts = structure(list(structure(list(statusCode = structure(logical(0), tags = list(type = "string")), message = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure"))), tags = list(type = "list")), source = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), gitCloneDepth = structure(logical(0), tags = list(type = "integer")), gitSubmodulesConfig = structure(list(fetchSubmodules = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure")), buildspec = structure(logical(0), tags = list(type = "string")), auth = structure(list(type = structure(logical(0), tags = list(type = "string")), resource = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), reportBuildStatus = structure(logical(0), tags = list(type = "boolean")), buildStatusConfig = structure(list(context = structure(logical(0), tags = list(type = "string")), targetUrl = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), insecureSsl = structure(logical(0), tags = list(type = "boolean")), sourceIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), secondarySources = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), gitCloneDepth = structure(logical(0), tags = list(type = "integer")), gitSubmodulesConfig = structure(list(fetchSubmodules = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure")), buildspec = structure(logical(0), tags = list(type = "string")), auth = structure(list(type = structure(logical(0), tags = list(type = "string")), resource = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), reportBuildStatus = structure(logical(0), tags = list(type = "boolean")), buildStatusConfig = structure(list(context = structure(logical(0), tags = list(type = "string")), targetUrl = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), insecureSsl = structure(logical(0), tags = list(type = "boolean")), sourceIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), secondarySourceVersions = structure(list(structure(list(sourceIdentifier = structure(logical(0), tags = list(type = "string")), sourceVersion = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), artifacts = structure(list(location = structure(logical(0), tags = list(type = "string")), sha256sum = structure(logical(0), tags = list(type = "string")), md5sum = structure(logical(0), tags = list(type = "string")), overrideArtifactName = structure(logical(0), tags = list(type = "boolean")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean")), artifactIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), secondaryArtifacts = structure(list(structure(list(location = structure(logical(0), tags = list(type = "string")), sha256sum = structure(logical(0), tags = list(type = "string")), md5sum = structure(logical(0), tags = list(type = "string")), overrideArtifactName = structure(logical(0), tags = list(type = "boolean")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean")), artifactIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), cache = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), modes = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")), environment = structure(list(type = structure(logical(0), tags = list(type = "string")), image = structure(logical(0), tags = list(type = "string")), computeType = structure(logical(0), tags = list(type = "string")), environmentVariables = structure(list(structure(list(name = structure(logical(0), tags = list(type = "string")), value = structure(logical(0), tags = list(type = "string")), type = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), privilegedMode = structure(logical(0), tags = list(type = "boolean")), certificate = structure(logical(0), tags = list(type = "string")), registryCredential = structure(list(credential = structure(logical(0), tags = list(type = "string")), credentialProvider = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), imagePullCredentialsType = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), serviceRole = structure(logical(0), tags = list(type = "string")), logs = structure(list(groupName = structure(logical(0), tags = list(type = "string")), streamName = structure(logical(0), tags = list(type = "string")), deepLink = structure(logical(0), tags = list(type = "string")), s3DeepLink = structure(logical(0), tags = list(type = "string")), cloudWatchLogsArn = structure(logical(0), tags = list(type = "string")), s3LogsArn = structure(logical(0), tags = list(type = "string")), cloudWatchLogs = structure(list(status = structure(logical(0), tags = list(type = "string")), groupName = structure(logical(0), tags = list(type = "string")), streamName = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), s3Logs = structure(list(status = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure"))), tags = list(type = "structure")), timeoutInMinutes = structure(logical(0), tags = list(type = "integer")), queuedTimeoutInMinutes = structure(logical(0), tags = list(type = "integer")), buildComplete = structure(logical(0), tags = list(type = "boolean")), initiator = structure(logical(0), tags = list(type = "string")), vpcConfig = structure(list(vpcId = structure(logical(0), tags = list(type = "string")), subnets = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list")), securityGroupIds = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")), networkInterface = structure(list(subnetId = structure(logical(0), tags = list(type = "string")), networkInterfaceId = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), encryptionKey = structure(logical(0), tags = list(type = "string")), exportedEnvironmentVariables = structure(list(structure(list(name = structure(logical(0), tags = list(type = "string")), value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), reportArns = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list")), fileSystemLocations = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), mountPoint = structure(logical(0), tags = list(type = "string")), identifier = structure(logical(0), tags = list(type = "string")), mountOptions = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), debugSession = structure(list(sessionEnabled = structure(logical(0), tags = list(type = "boolean")), sessionTarget = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), buildBatchArn = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$retry_build_batch_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(id = structure(logical(0), tags = list(type = "string")), idempotencyToken = structure(logical(0), tags = list(type = "string")), retryType = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$retry_build_batch_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(buildBatch = structure(list(id = structure(logical(0), tags = list(type = "string")), arn = structure(logical(0), tags = list(type = "string")), startTime = structure(logical(0), tags = list(type = "timestamp")), endTime = structure(logical(0), tags = list(type = "timestamp")), currentPhase = structure(logical(0), tags = list(type = "string")), buildBatchStatus = structure(logical(0), tags = list(type = "string")), sourceVersion = structure(logical(0), tags = list(type = "string")), resolvedSourceVersion = structure(logical(0), tags = list(type = "string")), projectName = structure(logical(0), tags = list(type = "string")), phases = structure(list(structure(list(phaseType = structure(logical(0), tags = list(type = "string")), phaseStatus = structure(logical(0), tags = list(type = "string")), startTime = structure(logical(0), tags = list(type = "timestamp")), endTime = structure(logical(0), tags = list(type = "timestamp")), durationInSeconds = structure(logical(0), tags = list(type = "long")), contexts = structure(list(structure(list(statusCode = structure(logical(0), tags = list(type = "string")), message = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure"))), tags = list(type = "list")), source = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), gitCloneDepth = structure(logical(0), tags = list(type = "integer")), gitSubmodulesConfig = structure(list(fetchSubmodules = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure")), buildspec = structure(logical(0), tags = list(type = "string")), auth = structure(list(type = structure(logical(0), tags = list(type = "string")), resource = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), reportBuildStatus = structure(logical(0), tags = list(type = "boolean")), buildStatusConfig = structure(list(context = structure(logical(0), tags = list(type = "string")), targetUrl = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), insecureSsl = structure(logical(0), tags = list(type = "boolean")), sourceIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), secondarySources = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), gitCloneDepth = structure(logical(0), tags = list(type = "integer")), gitSubmodulesConfig = structure(list(fetchSubmodules = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure")), buildspec = structure(logical(0), tags = list(type = "string")), auth = structure(list(type = structure(logical(0), tags = list(type = "string")), resource = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), reportBuildStatus = structure(logical(0), tags = list(type = "boolean")), buildStatusConfig = structure(list(context = structure(logical(0), tags = list(type = "string")), targetUrl = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), insecureSsl = structure(logical(0), tags = list(type = "boolean")), sourceIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), secondarySourceVersions = structure(list(structure(list(sourceIdentifier = structure(logical(0), tags = list(type = "string")), sourceVersion = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), artifacts = structure(list(location = structure(logical(0), tags = list(type = "string")), sha256sum = structure(logical(0), tags = list(type = "string")), md5sum = structure(logical(0), tags = list(type = "string")), overrideArtifactName = structure(logical(0), tags = list(type = "boolean")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean")), artifactIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), secondaryArtifacts = structure(list(structure(list(location = structure(logical(0), tags = list(type = "string")), sha256sum = structure(logical(0), tags = list(type = "string")), md5sum = structure(logical(0), tags = list(type = "string")), overrideArtifactName = structure(logical(0), tags = list(type = "boolean")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean")), artifactIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), cache = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), modes = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")), environment = structure(list(type = structure(logical(0), tags = list(type = "string")), image = structure(logical(0), tags = list(type = "string")), computeType = structure(logical(0), tags = list(type = "string")), environmentVariables = structure(list(structure(list(name = structure(logical(0), tags = list(type = "string")), value = structure(logical(0), tags = list(type = "string")), type = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), privilegedMode = structure(logical(0), tags = list(type = "boolean")), certificate = structure(logical(0), tags = list(type = "string")), registryCredential = structure(list(credential = structure(logical(0), tags = list(type = "string")), credentialProvider = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), imagePullCredentialsType = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), serviceRole = structure(logical(0), tags = list(type = "string")), logConfig = structure(list(cloudWatchLogs = structure(list(status = structure(logical(0), tags = list(type = "string")), groupName = structure(logical(0), tags = list(type = "string")), streamName = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), s3Logs = structure(list(status = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure"))), tags = list(type = "structure")), buildTimeoutInMinutes = structure(logical(0), tags = list(type = "integer")), queuedTimeoutInMinutes = structure(logical(0), tags = list(type = "integer")), complete = structure(logical(0), tags = list(type = "boolean")), initiator = structure(logical(0), tags = list(type = "string")), vpcConfig = structure(list(vpcId = structure(logical(0), tags = list(type = "string")), subnets = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list")), securityGroupIds = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")), encryptionKey = structure(logical(0), tags = list(type = "string")), buildBatchNumber = structure(logical(0), tags = list(type = "long")), fileSystemLocations = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), mountPoint = structure(logical(0), tags = list(type = "string")), identifier = structure(logical(0), tags = list(type = "string")), mountOptions = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), buildBatchConfig = structure(list(serviceRole = structure(logical(0), tags = list(type = "string")), combineArtifacts = structure(logical(0), tags = list(type = "boolean")), restrictions = structure(list(maximumBuildsAllowed = structure(logical(0), tags = list(type = "integer")), computeTypesAllowed = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")), timeoutInMins = structure(logical(0), tags = list(type = "integer"))), tags = list(type = "structure")), buildGroups = structure(list(structure(list(identifier = structure(logical(0), tags = list(type = "string")), dependsOn = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list")), ignoreFailure = structure(logical(0), tags = list(type = "boolean")), currentBuildSummary = structure(list(arn = structure(logical(0), tags = list(type = "string")), requestedOn = structure(logical(0), tags = list(type = "timestamp")), buildStatus = structure(logical(0), tags = list(type = "string")), primaryArtifact = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), identifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), secondaryArtifacts = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), identifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure")), priorBuildSummaryList = structure(list(structure(list(arn = structure(logical(0), tags = list(type = "string")), requestedOn = structure(logical(0), tags = list(type = "timestamp")), buildStatus = structure(logical(0), tags = list(type = "string")), primaryArtifact = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), identifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), secondaryArtifacts = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), identifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$start_build_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(projectName = structure(logical(0), tags = list(type = "string")), secondarySourcesOverride = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), gitCloneDepth = structure(logical(0), tags = list(type = "integer")), gitSubmodulesConfig = structure(list(fetchSubmodules = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure")), buildspec = structure(logical(0), tags = list(type = "string")), auth = structure(list(type = structure(logical(0), tags = list(type = "string")), resource = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), reportBuildStatus = structure(logical(0), tags = list(type = "boolean")), buildStatusConfig = structure(list(context = structure(logical(0), tags = list(type = "string")), targetUrl = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), insecureSsl = structure(logical(0), tags = list(type = "boolean")), sourceIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), secondarySourcesVersionOverride = structure(list(structure(list(sourceIdentifier = structure(logical(0), tags = list(type = "string")), sourceVersion = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), sourceVersion = structure(logical(0), tags = list(type = "string")), artifactsOverride = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), path = structure(logical(0), tags = list(type = "string")), namespaceType = structure(logical(0), tags = list(type = "string")), name = structure(logical(0), tags = list(type = "string")), packaging = structure(logical(0), tags = list(type = "string")), overrideArtifactName = structure(logical(0), tags = list(type = "boolean")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean")), artifactIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), secondaryArtifactsOverride = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), path = structure(logical(0), tags = list(type = "string")), namespaceType = structure(logical(0), tags = list(type = "string")), name = structure(logical(0), tags = list(type = "string")), packaging = structure(logical(0), tags = list(type = "string")), overrideArtifactName = structure(logical(0), tags = list(type = "boolean")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean")), artifactIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), environmentVariablesOverride = structure(list(structure(list(name = structure(logical(0), tags = list(type = "string")), value = structure(logical(0), tags = list(type = "string")), type = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), sourceTypeOverride = structure(logical(0), tags = list(type = "string")), sourceLocationOverride = structure(logical(0), tags = list(type = "string")), sourceAuthOverride = structure(list(type = structure(logical(0), tags = list(type = "string")), resource = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), gitCloneDepthOverride = structure(logical(0), tags = list(type = "integer")), gitSubmodulesConfigOverride = structure(list(fetchSubmodules = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure")), buildspecOverride = structure(logical(0), tags = list(type = "string")), insecureSslOverride = structure(logical(0), tags = list(type = "boolean")), reportBuildStatusOverride = structure(logical(0), tags = list(type = "boolean")), buildStatusConfigOverride = structure(list(context = structure(logical(0), tags = list(type = "string")), targetUrl = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), environmentTypeOverride = structure(logical(0), tags = list(type = "string")), imageOverride = structure(logical(0), tags = list(type = "string")), computeTypeOverride = structure(logical(0), tags = list(type = "string")), certificateOverride = structure(logical(0), tags = list(type = "string")), cacheOverride = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), modes = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")), serviceRoleOverride = structure(logical(0), tags = list(type = "string")), privilegedModeOverride = structure(logical(0), tags = list(type = "boolean")), timeoutInMinutesOverride = structure(logical(0), tags = list(type = "integer")), queuedTimeoutInMinutesOverride = structure(logical(0), tags = list(type = "integer")), encryptionKeyOverride = structure(logical(0), tags = list(type = "string")), idempotencyToken = structure(logical(0), tags = list(type = "string")), logsConfigOverride = structure(list(cloudWatchLogs = structure(list(status = structure(logical(0), tags = list(type = "string")), groupName = structure(logical(0), tags = list(type = "string")), streamName = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), s3Logs = structure(list(status = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure"))), tags = list(type = "structure")), registryCredentialOverride = structure(list(credential = structure(logical(0), tags = list(type = "string")), credentialProvider = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), imagePullCredentialsTypeOverride = structure(logical(0), tags = list(type = "string")), debugSessionEnabled = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$start_build_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(build = structure(list(id = structure(logical(0), tags = list(type = "string")), arn = structure(logical(0), tags = list(type = "string")), buildNumber = structure(logical(0), tags = list(type = "long")), startTime = structure(logical(0), tags = list(type = "timestamp")), endTime = structure(logical(0), tags = list(type = "timestamp")), currentPhase = structure(logical(0), tags = list(type = "string")), buildStatus = structure(logical(0), tags = list(type = "string")), sourceVersion = structure(logical(0), tags = list(type = "string")), resolvedSourceVersion = structure(logical(0), tags = list(type = "string")), projectName = structure(logical(0), tags = list(type = "string")), phases = structure(list(structure(list(phaseType = structure(logical(0), tags = list(type = "string")), phaseStatus = structure(logical(0), tags = list(type = "string")), startTime = structure(logical(0), tags = list(type = "timestamp")), endTime = structure(logical(0), tags = list(type = "timestamp")), durationInSeconds = structure(logical(0), tags = list(type = "long")), contexts = structure(list(structure(list(statusCode = structure(logical(0), tags = list(type = "string")), message = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure"))), tags = list(type = "list")), source = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), gitCloneDepth = structure(logical(0), tags = list(type = "integer")), gitSubmodulesConfig = structure(list(fetchSubmodules = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure")), buildspec = structure(logical(0), tags = list(type = "string")), auth = structure(list(type = structure(logical(0), tags = list(type = "string")), resource = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), reportBuildStatus = structure(logical(0), tags = list(type = "boolean")), buildStatusConfig = structure(list(context = structure(logical(0), tags = list(type = "string")), targetUrl = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), insecureSsl = structure(logical(0), tags = list(type = "boolean")), sourceIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), secondarySources = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), gitCloneDepth = structure(logical(0), tags = list(type = "integer")), gitSubmodulesConfig = structure(list(fetchSubmodules = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure")), buildspec = structure(logical(0), tags = list(type = "string")), auth = structure(list(type = structure(logical(0), tags = list(type = "string")), resource = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), reportBuildStatus = structure(logical(0), tags = list(type = "boolean")), buildStatusConfig = structure(list(context = structure(logical(0), tags = list(type = "string")), targetUrl = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), insecureSsl = structure(logical(0), tags = list(type = "boolean")), sourceIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), secondarySourceVersions = structure(list(structure(list(sourceIdentifier = structure(logical(0), tags = list(type = "string")), sourceVersion = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), artifacts = structure(list(location = structure(logical(0), tags = list(type = "string")), sha256sum = structure(logical(0), tags = list(type = "string")), md5sum = structure(logical(0), tags = list(type = "string")), overrideArtifactName = structure(logical(0), tags = list(type = "boolean")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean")), artifactIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), secondaryArtifacts = structure(list(structure(list(location = structure(logical(0), tags = list(type = "string")), sha256sum = structure(logical(0), tags = list(type = "string")), md5sum = structure(logical(0), tags = list(type = "string")), overrideArtifactName = structure(logical(0), tags = list(type = "boolean")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean")), artifactIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), cache = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), modes = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")), environment = structure(list(type = structure(logical(0), tags = list(type = "string")), image = structure(logical(0), tags = list(type = "string")), computeType = structure(logical(0), tags = list(type = "string")), environmentVariables = structure(list(structure(list(name = structure(logical(0), tags = list(type = "string")), value = structure(logical(0), tags = list(type = "string")), type = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), privilegedMode = structure(logical(0), tags = list(type = "boolean")), certificate = structure(logical(0), tags = list(type = "string")), registryCredential = structure(list(credential = structure(logical(0), tags = list(type = "string")), credentialProvider = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), imagePullCredentialsType = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), serviceRole = structure(logical(0), tags = list(type = "string")), logs = structure(list(groupName = structure(logical(0), tags = list(type = "string")), streamName = structure(logical(0), tags = list(type = "string")), deepLink = structure(logical(0), tags = list(type = "string")), s3DeepLink = structure(logical(0), tags = list(type = "string")), cloudWatchLogsArn = structure(logical(0), tags = list(type = "string")), s3LogsArn = structure(logical(0), tags = list(type = "string")), cloudWatchLogs = structure(list(status = structure(logical(0), tags = list(type = "string")), groupName = structure(logical(0), tags = list(type = "string")), streamName = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), s3Logs = structure(list(status = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure"))), tags = list(type = "structure")), timeoutInMinutes = structure(logical(0), tags = list(type = "integer")), queuedTimeoutInMinutes = structure(logical(0), tags = list(type = "integer")), buildComplete = structure(logical(0), tags = list(type = "boolean")), initiator = structure(logical(0), tags = list(type = "string")), vpcConfig = structure(list(vpcId = structure(logical(0), tags = list(type = "string")), subnets = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list")), securityGroupIds = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")), networkInterface = structure(list(subnetId = structure(logical(0), tags = list(type = "string")), networkInterfaceId = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), encryptionKey = structure(logical(0), tags = list(type = "string")), exportedEnvironmentVariables = structure(list(structure(list(name = structure(logical(0), tags = list(type = "string")), value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), reportArns = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list")), fileSystemLocations = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), mountPoint = structure(logical(0), tags = list(type = "string")), identifier = structure(logical(0), tags = list(type = "string")), mountOptions = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), debugSession = structure(list(sessionEnabled = structure(logical(0), tags = list(type = "boolean")), sessionTarget = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), buildBatchArn = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$start_build_batch_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(projectName = structure(logical(0), tags = list(type = "string")), secondarySourcesOverride = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), gitCloneDepth = structure(logical(0), tags = list(type = "integer")), gitSubmodulesConfig = structure(list(fetchSubmodules = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure")), buildspec = structure(logical(0), tags = list(type = "string")), auth = structure(list(type = structure(logical(0), tags = list(type = "string")), resource = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), reportBuildStatus = structure(logical(0), tags = list(type = "boolean")), buildStatusConfig = structure(list(context = structure(logical(0), tags = list(type = "string")), targetUrl = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), insecureSsl = structure(logical(0), tags = list(type = "boolean")), sourceIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), secondarySourcesVersionOverride = structure(list(structure(list(sourceIdentifier = structure(logical(0), tags = list(type = "string")), sourceVersion = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), sourceVersion = structure(logical(0), tags = list(type = "string")), artifactsOverride = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), path = structure(logical(0), tags = list(type = "string")), namespaceType = structure(logical(0), tags = list(type = "string")), name = structure(logical(0), tags = list(type = "string")), packaging = structure(logical(0), tags = list(type = "string")), overrideArtifactName = structure(logical(0), tags = list(type = "boolean")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean")), artifactIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), secondaryArtifactsOverride = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), path = structure(logical(0), tags = list(type = "string")), namespaceType = structure(logical(0), tags = list(type = "string")), name = structure(logical(0), tags = list(type = "string")), packaging = structure(logical(0), tags = list(type = "string")), overrideArtifactName = structure(logical(0), tags = list(type = "boolean")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean")), artifactIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), environmentVariablesOverride = structure(list(structure(list(name = structure(logical(0), tags = list(type = "string")), value = structure(logical(0), tags = list(type = "string")), type = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), sourceTypeOverride = structure(logical(0), tags = list(type = "string")), sourceLocationOverride = structure(logical(0), tags = list(type = "string")), sourceAuthOverride = structure(list(type = structure(logical(0), tags = list(type = "string")), resource = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), gitCloneDepthOverride = structure(logical(0), tags = list(type = "integer")), gitSubmodulesConfigOverride = structure(list(fetchSubmodules = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure")), buildspecOverride = structure(logical(0), tags = list(type = "string")), insecureSslOverride = structure(logical(0), tags = list(type = "boolean")), reportBuildBatchStatusOverride = structure(logical(0), tags = list(type = "boolean")), environmentTypeOverride = structure(logical(0), tags = list(type = "string")), imageOverride = structure(logical(0), tags = list(type = "string")), computeTypeOverride = structure(logical(0), tags = list(type = "string")), certificateOverride = structure(logical(0), tags = list(type = "string")), cacheOverride = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), modes = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")), serviceRoleOverride = structure(logical(0), tags = list(type = "string")), privilegedModeOverride = structure(logical(0), tags = list(type = "boolean")), buildTimeoutInMinutesOverride = structure(logical(0), tags = list(type = "integer")), queuedTimeoutInMinutesOverride = structure(logical(0), tags = list(type = "integer")), encryptionKeyOverride = structure(logical(0), tags = list(type = "string")), idempotencyToken = structure(logical(0), tags = list(type = "string")), logsConfigOverride = structure(list(cloudWatchLogs = structure(list(status = structure(logical(0), tags = list(type = "string")), groupName = structure(logical(0), tags = list(type = "string")), streamName = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), s3Logs = structure(list(status = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure"))), tags = list(type = "structure")), registryCredentialOverride = structure(list(credential = structure(logical(0), tags = list(type = "string")), credentialProvider = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), imagePullCredentialsTypeOverride = structure(logical(0), tags = list(type = "string")), buildBatchConfigOverride = structure(list(serviceRole = structure(logical(0), tags = list(type = "string")), combineArtifacts = structure(logical(0), tags = list(type = "boolean")), restrictions = structure(list(maximumBuildsAllowed = structure(logical(0), tags = list(type = "integer")), computeTypesAllowed = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")), timeoutInMins = structure(logical(0), tags = list(type = "integer"))), tags = list(type = "structure"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$start_build_batch_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(buildBatch = structure(list(id = structure(logical(0), tags = list(type = "string")), arn = structure(logical(0), tags = list(type = "string")), startTime = structure(logical(0), tags = list(type = "timestamp")), endTime = structure(logical(0), tags = list(type = "timestamp")), currentPhase = structure(logical(0), tags = list(type = "string")), buildBatchStatus = structure(logical(0), tags = list(type = "string")), sourceVersion = structure(logical(0), tags = list(type = "string")), resolvedSourceVersion = structure(logical(0), tags = list(type = "string")), projectName = structure(logical(0), tags = list(type = "string")), phases = structure(list(structure(list(phaseType = structure(logical(0), tags = list(type = "string")), phaseStatus = structure(logical(0), tags = list(type = "string")), startTime = structure(logical(0), tags = list(type = "timestamp")), endTime = structure(logical(0), tags = list(type = "timestamp")), durationInSeconds = structure(logical(0), tags = list(type = "long")), contexts = structure(list(structure(list(statusCode = structure(logical(0), tags = list(type = "string")), message = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure"))), tags = list(type = "list")), source = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), gitCloneDepth = structure(logical(0), tags = list(type = "integer")), gitSubmodulesConfig = structure(list(fetchSubmodules = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure")), buildspec = structure(logical(0), tags = list(type = "string")), auth = structure(list(type = structure(logical(0), tags = list(type = "string")), resource = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), reportBuildStatus = structure(logical(0), tags = list(type = "boolean")), buildStatusConfig = structure(list(context = structure(logical(0), tags = list(type = "string")), targetUrl = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), insecureSsl = structure(logical(0), tags = list(type = "boolean")), sourceIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), secondarySources = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), gitCloneDepth = structure(logical(0), tags = list(type = "integer")), gitSubmodulesConfig = structure(list(fetchSubmodules = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure")), buildspec = structure(logical(0), tags = list(type = "string")), auth = structure(list(type = structure(logical(0), tags = list(type = "string")), resource = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), reportBuildStatus = structure(logical(0), tags = list(type = "boolean")), buildStatusConfig = structure(list(context = structure(logical(0), tags = list(type = "string")), targetUrl = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), insecureSsl = structure(logical(0), tags = list(type = "boolean")), sourceIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), secondarySourceVersions = structure(list(structure(list(sourceIdentifier = structure(logical(0), tags = list(type = "string")), sourceVersion = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), artifacts = structure(list(location = structure(logical(0), tags = list(type = "string")), sha256sum = structure(logical(0), tags = list(type = "string")), md5sum = structure(logical(0), tags = list(type = "string")), overrideArtifactName = structure(logical(0), tags = list(type = "boolean")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean")), artifactIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), secondaryArtifacts = structure(list(structure(list(location = structure(logical(0), tags = list(type = "string")), sha256sum = structure(logical(0), tags = list(type = "string")), md5sum = structure(logical(0), tags = list(type = "string")), overrideArtifactName = structure(logical(0), tags = list(type = "boolean")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean")), artifactIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), cache = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), modes = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")), environment = structure(list(type = structure(logical(0), tags = list(type = "string")), image = structure(logical(0), tags = list(type = "string")), computeType = structure(logical(0), tags = list(type = "string")), environmentVariables = structure(list(structure(list(name = structure(logical(0), tags = list(type = "string")), value = structure(logical(0), tags = list(type = "string")), type = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), privilegedMode = structure(logical(0), tags = list(type = "boolean")), certificate = structure(logical(0), tags = list(type = "string")), registryCredential = structure(list(credential = structure(logical(0), tags = list(type = "string")), credentialProvider = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), imagePullCredentialsType = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), serviceRole = structure(logical(0), tags = list(type = "string")), logConfig = structure(list(cloudWatchLogs = structure(list(status = structure(logical(0), tags = list(type = "string")), groupName = structure(logical(0), tags = list(type = "string")), streamName = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), s3Logs = structure(list(status = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure"))), tags = list(type = "structure")), buildTimeoutInMinutes = structure(logical(0), tags = list(type = "integer")), queuedTimeoutInMinutes = structure(logical(0), tags = list(type = "integer")), complete = structure(logical(0), tags = list(type = "boolean")), initiator = structure(logical(0), tags = list(type = "string")), vpcConfig = structure(list(vpcId = structure(logical(0), tags = list(type = "string")), subnets = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list")), securityGroupIds = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")), encryptionKey = structure(logical(0), tags = list(type = "string")), buildBatchNumber = structure(logical(0), tags = list(type = "long")), fileSystemLocations = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), mountPoint = structure(logical(0), tags = list(type = "string")), identifier = structure(logical(0), tags = list(type = "string")), mountOptions = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), buildBatchConfig = structure(list(serviceRole = structure(logical(0), tags = list(type = "string")), combineArtifacts = structure(logical(0), tags = list(type = "boolean")), restrictions = structure(list(maximumBuildsAllowed = structure(logical(0), tags = list(type = "integer")), computeTypesAllowed = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")), timeoutInMins = structure(logical(0), tags = list(type = "integer"))), tags = list(type = "structure")), buildGroups = structure(list(structure(list(identifier = structure(logical(0), tags = list(type = "string")), dependsOn = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list")), ignoreFailure = structure(logical(0), tags = list(type = "boolean")), currentBuildSummary = structure(list(arn = structure(logical(0), tags = list(type = "string")), requestedOn = structure(logical(0), tags = list(type = "timestamp")), buildStatus = structure(logical(0), tags = list(type = "string")), primaryArtifact = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), identifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), secondaryArtifacts = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), identifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure")), priorBuildSummaryList = structure(list(structure(list(arn = structure(logical(0), tags = list(type = "string")), requestedOn = structure(logical(0), tags = list(type = "timestamp")), buildStatus = structure(logical(0), tags = list(type = "string")), primaryArtifact = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), identifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), secondaryArtifacts = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), identifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$stop_build_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(id = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$stop_build_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(build = structure(list(id = structure(logical(0), tags = list(type = "string")), arn = structure(logical(0), tags = list(type = "string")), buildNumber = structure(logical(0), tags = list(type = "long")), startTime = structure(logical(0), tags = list(type = "timestamp")), endTime = structure(logical(0), tags = list(type = "timestamp")), currentPhase = structure(logical(0), tags = list(type = "string")), buildStatus = structure(logical(0), tags = list(type = "string")), sourceVersion = structure(logical(0), tags = list(type = "string")), resolvedSourceVersion = structure(logical(0), tags = list(type = "string")), projectName = structure(logical(0), tags = list(type = "string")), phases = structure(list(structure(list(phaseType = structure(logical(0), tags = list(type = "string")), phaseStatus = structure(logical(0), tags = list(type = "string")), startTime = structure(logical(0), tags = list(type = "timestamp")), endTime = structure(logical(0), tags = list(type = "timestamp")), durationInSeconds = structure(logical(0), tags = list(type = "long")), contexts = structure(list(structure(list(statusCode = structure(logical(0), tags = list(type = "string")), message = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure"))), tags = list(type = "list")), source = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), gitCloneDepth = structure(logical(0), tags = list(type = "integer")), gitSubmodulesConfig = structure(list(fetchSubmodules = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure")), buildspec = structure(logical(0), tags = list(type = "string")), auth = structure(list(type = structure(logical(0), tags = list(type = "string")), resource = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), reportBuildStatus = structure(logical(0), tags = list(type = "boolean")), buildStatusConfig = structure(list(context = structure(logical(0), tags = list(type = "string")), targetUrl = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), insecureSsl = structure(logical(0), tags = list(type = "boolean")), sourceIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), secondarySources = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), gitCloneDepth = structure(logical(0), tags = list(type = "integer")), gitSubmodulesConfig = structure(list(fetchSubmodules = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure")), buildspec = structure(logical(0), tags = list(type = "string")), auth = structure(list(type = structure(logical(0), tags = list(type = "string")), resource = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), reportBuildStatus = structure(logical(0), tags = list(type = "boolean")), buildStatusConfig = structure(list(context = structure(logical(0), tags = list(type = "string")), targetUrl = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), insecureSsl = structure(logical(0), tags = list(type = "boolean")), sourceIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), secondarySourceVersions = structure(list(structure(list(sourceIdentifier = structure(logical(0), tags = list(type = "string")), sourceVersion = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), artifacts = structure(list(location = structure(logical(0), tags = list(type = "string")), sha256sum = structure(logical(0), tags = list(type = "string")), md5sum = structure(logical(0), tags = list(type = "string")), overrideArtifactName = structure(logical(0), tags = list(type = "boolean")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean")), artifactIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), secondaryArtifacts = structure(list(structure(list(location = structure(logical(0), tags = list(type = "string")), sha256sum = structure(logical(0), tags = list(type = "string")), md5sum = structure(logical(0), tags = list(type = "string")), overrideArtifactName = structure(logical(0), tags = list(type = "boolean")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean")), artifactIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), cache = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), modes = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")), environment = structure(list(type = structure(logical(0), tags = list(type = "string")), image = structure(logical(0), tags = list(type = "string")), computeType = structure(logical(0), tags = list(type = "string")), environmentVariables = structure(list(structure(list(name = structure(logical(0), tags = list(type = "string")), value = structure(logical(0), tags = list(type = "string")), type = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), privilegedMode = structure(logical(0), tags = list(type = "boolean")), certificate = structure(logical(0), tags = list(type = "string")), registryCredential = structure(list(credential = structure(logical(0), tags = list(type = "string")), credentialProvider = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), imagePullCredentialsType = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), serviceRole = structure(logical(0), tags = list(type = "string")), logs = structure(list(groupName = structure(logical(0), tags = list(type = "string")), streamName = structure(logical(0), tags = list(type = "string")), deepLink = structure(logical(0), tags = list(type = "string")), s3DeepLink = structure(logical(0), tags = list(type = "string")), cloudWatchLogsArn = structure(logical(0), tags = list(type = "string")), s3LogsArn = structure(logical(0), tags = list(type = "string")), cloudWatchLogs = structure(list(status = structure(logical(0), tags = list(type = "string")), groupName = structure(logical(0), tags = list(type = "string")), streamName = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), s3Logs = structure(list(status = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure"))), tags = list(type = "structure")), timeoutInMinutes = structure(logical(0), tags = list(type = "integer")), queuedTimeoutInMinutes = structure(logical(0), tags = list(type = "integer")), buildComplete = structure(logical(0), tags = list(type = "boolean")), initiator = structure(logical(0), tags = list(type = "string")), vpcConfig = structure(list(vpcId = structure(logical(0), tags = list(type = "string")), subnets = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list")), securityGroupIds = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")), networkInterface = structure(list(subnetId = structure(logical(0), tags = list(type = "string")), networkInterfaceId = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), encryptionKey = structure(logical(0), tags = list(type = "string")), exportedEnvironmentVariables = structure(list(structure(list(name = structure(logical(0), tags = list(type = "string")), value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), reportArns = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list")), fileSystemLocations = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), mountPoint = structure(logical(0), tags = list(type = "string")), identifier = structure(logical(0), tags = list(type = "string")), mountOptions = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), debugSession = structure(list(sessionEnabled = structure(logical(0), tags = list(type = "boolean")), sessionTarget = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), buildBatchArn = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$stop_build_batch_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(id = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$stop_build_batch_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(buildBatch = structure(list(id = structure(logical(0), tags = list(type = "string")), arn = structure(logical(0), tags = list(type = "string")), startTime = structure(logical(0), tags = list(type = "timestamp")), endTime = structure(logical(0), tags = list(type = "timestamp")), currentPhase = structure(logical(0), tags = list(type = "string")), buildBatchStatus = structure(logical(0), tags = list(type = "string")), sourceVersion = structure(logical(0), tags = list(type = "string")), resolvedSourceVersion = structure(logical(0), tags = list(type = "string")), projectName = structure(logical(0), tags = list(type = "string")), phases = structure(list(structure(list(phaseType = structure(logical(0), tags = list(type = "string")), phaseStatus = structure(logical(0), tags = list(type = "string")), startTime = structure(logical(0), tags = list(type = "timestamp")), endTime = structure(logical(0), tags = list(type = "timestamp")), durationInSeconds = structure(logical(0), tags = list(type = "long")), contexts = structure(list(structure(list(statusCode = structure(logical(0), tags = list(type = "string")), message = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure"))), tags = list(type = "list")), source = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), gitCloneDepth = structure(logical(0), tags = list(type = "integer")), gitSubmodulesConfig = structure(list(fetchSubmodules = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure")), buildspec = structure(logical(0), tags = list(type = "string")), auth = structure(list(type = structure(logical(0), tags = list(type = "string")), resource = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), reportBuildStatus = structure(logical(0), tags = list(type = "boolean")), buildStatusConfig = structure(list(context = structure(logical(0), tags = list(type = "string")), targetUrl = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), insecureSsl = structure(logical(0), tags = list(type = "boolean")), sourceIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), secondarySources = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), gitCloneDepth = structure(logical(0), tags = list(type = "integer")), gitSubmodulesConfig = structure(list(fetchSubmodules = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure")), buildspec = structure(logical(0), tags = list(type = "string")), auth = structure(list(type = structure(logical(0), tags = list(type = "string")), resource = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), reportBuildStatus = structure(logical(0), tags = list(type = "boolean")), buildStatusConfig = structure(list(context = structure(logical(0), tags = list(type = "string")), targetUrl = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), insecureSsl = structure(logical(0), tags = list(type = "boolean")), sourceIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), secondarySourceVersions = structure(list(structure(list(sourceIdentifier = structure(logical(0), tags = list(type = "string")), sourceVersion = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), artifacts = structure(list(location = structure(logical(0), tags = list(type = "string")), sha256sum = structure(logical(0), tags = list(type = "string")), md5sum = structure(logical(0), tags = list(type = "string")), overrideArtifactName = structure(logical(0), tags = list(type = "boolean")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean")), artifactIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), secondaryArtifacts = structure(list(structure(list(location = structure(logical(0), tags = list(type = "string")), sha256sum = structure(logical(0), tags = list(type = "string")), md5sum = structure(logical(0), tags = list(type = "string")), overrideArtifactName = structure(logical(0), tags = list(type = "boolean")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean")), artifactIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), cache = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), modes = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")), environment = structure(list(type = structure(logical(0), tags = list(type = "string")), image = structure(logical(0), tags = list(type = "string")), computeType = structure(logical(0), tags = list(type = "string")), environmentVariables = structure(list(structure(list(name = structure(logical(0), tags = list(type = "string")), value = structure(logical(0), tags = list(type = "string")), type = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), privilegedMode = structure(logical(0), tags = list(type = "boolean")), certificate = structure(logical(0), tags = list(type = "string")), registryCredential = structure(list(credential = structure(logical(0), tags = list(type = "string")), credentialProvider = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), imagePullCredentialsType = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), serviceRole = structure(logical(0), tags = list(type = "string")), logConfig = structure(list(cloudWatchLogs = structure(list(status = structure(logical(0), tags = list(type = "string")), groupName = structure(logical(0), tags = list(type = "string")), streamName = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), s3Logs = structure(list(status = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure"))), tags = list(type = "structure")), buildTimeoutInMinutes = structure(logical(0), tags = list(type = "integer")), queuedTimeoutInMinutes = structure(logical(0), tags = list(type = "integer")), complete = structure(logical(0), tags = list(type = "boolean")), initiator = structure(logical(0), tags = list(type = "string")), vpcConfig = structure(list(vpcId = structure(logical(0), tags = list(type = "string")), subnets = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list")), securityGroupIds = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")), encryptionKey = structure(logical(0), tags = list(type = "string")), buildBatchNumber = structure(logical(0), tags = list(type = "long")), fileSystemLocations = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), mountPoint = structure(logical(0), tags = list(type = "string")), identifier = structure(logical(0), tags = list(type = "string")), mountOptions = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), buildBatchConfig = structure(list(serviceRole = structure(logical(0), tags = list(type = "string")), combineArtifacts = structure(logical(0), tags = list(type = "boolean")), restrictions = structure(list(maximumBuildsAllowed = structure(logical(0), tags = list(type = "integer")), computeTypesAllowed = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")), timeoutInMins = structure(logical(0), tags = list(type = "integer"))), tags = list(type = "structure")), buildGroups = structure(list(structure(list(identifier = structure(logical(0), tags = list(type = "string")), dependsOn = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list")), ignoreFailure = structure(logical(0), tags = list(type = "boolean")), currentBuildSummary = structure(list(arn = structure(logical(0), tags = list(type = "string")), requestedOn = structure(logical(0), tags = list(type = "timestamp")), buildStatus = structure(logical(0), tags = list(type = "string")), primaryArtifact = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), identifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), secondaryArtifacts = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), identifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure")), priorBuildSummaryList = structure(list(structure(list(arn = structure(logical(0), tags = list(type = "string")), requestedOn = structure(logical(0), tags = list(type = "timestamp")), buildStatus = structure(logical(0), tags = list(type = "string")), primaryArtifact = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), identifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), secondaryArtifacts = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), identifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$update_project_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(name = structure(logical(0), tags = list(type = "string")), description = structure(logical(0), tags = list(type = "string")), source = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), gitCloneDepth = structure(logical(0), tags = list(type = "integer")), gitSubmodulesConfig = structure(list(fetchSubmodules = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure")), buildspec = structure(logical(0), tags = list(type = "string")), auth = structure(list(type = structure(logical(0), tags = list(type = "string")), resource = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), reportBuildStatus = structure(logical(0), tags = list(type = "boolean")), buildStatusConfig = structure(list(context = structure(logical(0), tags = list(type = "string")), targetUrl = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), insecureSsl = structure(logical(0), tags = list(type = "boolean")), sourceIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), secondarySources = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), gitCloneDepth = structure(logical(0), tags = list(type = "integer")), gitSubmodulesConfig = structure(list(fetchSubmodules = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure")), buildspec = structure(logical(0), tags = list(type = "string")), auth = structure(list(type = structure(logical(0), tags = list(type = "string")), resource = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), reportBuildStatus = structure(logical(0), tags = list(type = "boolean")), buildStatusConfig = structure(list(context = structure(logical(0), tags = list(type = "string")), targetUrl = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), insecureSsl = structure(logical(0), tags = list(type = "boolean")), sourceIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), sourceVersion = structure(logical(0), tags = list(type = "string")), secondarySourceVersions = structure(list(structure(list(sourceIdentifier = structure(logical(0), tags = list(type = "string")), sourceVersion = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), artifacts = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), path = structure(logical(0), tags = list(type = "string")), namespaceType = structure(logical(0), tags = list(type = "string")), name = structure(logical(0), tags = list(type = "string")), packaging = structure(logical(0), tags = list(type = "string")), overrideArtifactName = structure(logical(0), tags = list(type = "boolean")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean")), artifactIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), secondaryArtifacts = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), path = structure(logical(0), tags = list(type = "string")), namespaceType = structure(logical(0), tags = list(type = "string")), name = structure(logical(0), tags = list(type = "string")), packaging = structure(logical(0), tags = list(type = "string")), overrideArtifactName = structure(logical(0), tags = list(type = "boolean")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean")), artifactIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), cache = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), modes = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")), environment = structure(list(type = structure(logical(0), tags = list(type = "string")), image = structure(logical(0), tags = list(type = "string")), computeType = structure(logical(0), tags = list(type = "string")), environmentVariables = structure(list(structure(list(name = structure(logical(0), tags = list(type = "string")), value = structure(logical(0), tags = list(type = "string")), type = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), privilegedMode = structure(logical(0), tags = list(type = "boolean")), certificate = structure(logical(0), tags = list(type = "string")), registryCredential = structure(list(credential = structure(logical(0), tags = list(type = "string")), credentialProvider = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), imagePullCredentialsType = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), serviceRole = structure(logical(0), tags = list(type = "string")), timeoutInMinutes = structure(logical(0), tags = list(type = "integer")), queuedTimeoutInMinutes = structure(logical(0), tags = list(type = "integer")), encryptionKey = structure(logical(0), tags = list(type = "string")), tags = structure(list(structure(list(key = structure(logical(0), tags = list(type = "string")), value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), vpcConfig = structure(list(vpcId = structure(logical(0), tags = list(type = "string")), subnets = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list")), securityGroupIds = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")), badgeEnabled = structure(logical(0), tags = list(type = "boolean")), logsConfig = structure(list(cloudWatchLogs = structure(list(status = structure(logical(0), tags = list(type = "string")), groupName = structure(logical(0), tags = list(type = "string")), streamName = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), s3Logs = structure(list(status = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure"))), tags = list(type = "structure")), fileSystemLocations = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), mountPoint = structure(logical(0), tags = list(type = "string")), identifier = structure(logical(0), tags = list(type = "string")), mountOptions = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), buildBatchConfig = structure(list(serviceRole = structure(logical(0), tags = list(type = "string")), combineArtifacts = structure(logical(0), tags = list(type = "boolean")), restrictions = structure(list(maximumBuildsAllowed = structure(logical(0), tags = list(type = "integer")), computeTypesAllowed = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")), timeoutInMins = structure(logical(0), tags = list(type = "integer"))), tags = list(type = "structure"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$update_project_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(project = structure(list(name = structure(logical(0), tags = list(type = "string")), arn = structure(logical(0), tags = list(type = "string")), description = structure(logical(0), tags = list(type = "string")), source = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), gitCloneDepth = structure(logical(0), tags = list(type = "integer")), gitSubmodulesConfig = structure(list(fetchSubmodules = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure")), buildspec = structure(logical(0), tags = list(type = "string")), auth = structure(list(type = structure(logical(0), tags = list(type = "string")), resource = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), reportBuildStatus = structure(logical(0), tags = list(type = "boolean")), buildStatusConfig = structure(list(context = structure(logical(0), tags = list(type = "string")), targetUrl = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), insecureSsl = structure(logical(0), tags = list(type = "boolean")), sourceIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), secondarySources = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), gitCloneDepth = structure(logical(0), tags = list(type = "integer")), gitSubmodulesConfig = structure(list(fetchSubmodules = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure")), buildspec = structure(logical(0), tags = list(type = "string")), auth = structure(list(type = structure(logical(0), tags = list(type = "string")), resource = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), reportBuildStatus = structure(logical(0), tags = list(type = "boolean")), buildStatusConfig = structure(list(context = structure(logical(0), tags = list(type = "string")), targetUrl = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), insecureSsl = structure(logical(0), tags = list(type = "boolean")), sourceIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), sourceVersion = structure(logical(0), tags = list(type = "string")), secondarySourceVersions = structure(list(structure(list(sourceIdentifier = structure(logical(0), tags = list(type = "string")), sourceVersion = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), artifacts = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), path = structure(logical(0), tags = list(type = "string")), namespaceType = structure(logical(0), tags = list(type = "string")), name = structure(logical(0), tags = list(type = "string")), packaging = structure(logical(0), tags = list(type = "string")), overrideArtifactName = structure(logical(0), tags = list(type = "boolean")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean")), artifactIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), secondaryArtifacts = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), path = structure(logical(0), tags = list(type = "string")), namespaceType = structure(logical(0), tags = list(type = "string")), name = structure(logical(0), tags = list(type = "string")), packaging = structure(logical(0), tags = list(type = "string")), overrideArtifactName = structure(logical(0), tags = list(type = "boolean")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean")), artifactIdentifier = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), cache = structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), modes = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")), environment = structure(list(type = structure(logical(0), tags = list(type = "string")), image = structure(logical(0), tags = list(type = "string")), computeType = structure(logical(0), tags = list(type = "string")), environmentVariables = structure(list(structure(list(name = structure(logical(0), tags = list(type = "string")), value = structure(logical(0), tags = list(type = "string")), type = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), privilegedMode = structure(logical(0), tags = list(type = "boolean")), certificate = structure(logical(0), tags = list(type = "string")), registryCredential = structure(list(credential = structure(logical(0), tags = list(type = "string")), credentialProvider = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), imagePullCredentialsType = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), serviceRole = structure(logical(0), tags = list(type = "string")), timeoutInMinutes = structure(logical(0), tags = list(type = "integer")), queuedTimeoutInMinutes = structure(logical(0), tags = list(type = "integer")), encryptionKey = structure(logical(0), tags = list(type = "string")), tags = structure(list(structure(list(key = structure(logical(0), tags = list(type = "string")), value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), created = structure(logical(0), tags = list(type = "timestamp")), lastModified = structure(logical(0), tags = list(type = "timestamp")), webhook = structure(list(url = structure(logical(0), tags = list(type = "string")), payloadUrl = structure(logical(0), tags = list(type = "string")), secret = structure(logical(0), tags = list(type = "string")), branchFilter = structure(logical(0), tags = list(type = "string")), filterGroups = structure(list(structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), pattern = structure(logical(0), tags = list(type = "string")), excludeMatchedPattern = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "list")), buildType = structure(logical(0), tags = list(type = "string")), lastModifiedSecret = structure(logical(0), tags = list(type = "timestamp"))), tags = list(type = "structure")), vpcConfig = structure(list(vpcId = structure(logical(0), tags = list(type = "string")), subnets = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list")), securityGroupIds = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")), badge = structure(list(badgeEnabled = structure(logical(0), tags = list(type = "boolean")), badgeRequestUrl = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), logsConfig = structure(list(cloudWatchLogs = structure(list(status = structure(logical(0), tags = list(type = "string")), groupName = structure(logical(0), tags = list(type = "string")), streamName = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), s3Logs = structure(list(status = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure"))), tags = list(type = "structure")), fileSystemLocations = structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), location = structure(logical(0), tags = list(type = "string")), mountPoint = structure(logical(0), tags = list(type = "string")), identifier = structure(logical(0), tags = list(type = "string")), mountOptions = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), buildBatchConfig = structure(list(serviceRole = structure(logical(0), tags = list(type = "string")), combineArtifacts = structure(logical(0), tags = list(type = "boolean")), restrictions = structure(list(maximumBuildsAllowed = structure(logical(0), tags = list(type = "integer")), computeTypesAllowed = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")), timeoutInMins = structure(logical(0), tags = list(type = "integer"))), tags = list(type = "structure"))), tags = list(type = "structure"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$update_report_group_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(arn = structure(logical(0), tags = list(type = "string")), exportConfig = structure(list(exportConfigType = structure(logical(0), tags = list(type = "string")), s3Destination = structure(list(bucket = structure(logical(0), tags = list(type = "string")), path = structure(logical(0), tags = list(type = "string")), packaging = structure(logical(0), tags = list(type = "string")), encryptionKey = structure(logical(0), tags = list(type = "string")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure"))), tags = list(type = "structure")), tags = structure(list(structure(list(key = structure(logical(0), tags = list(type = "string")), value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$update_report_group_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(reportGroup = structure(list(arn = structure(logical(0), tags = list(type = "string")), name = structure(logical(0), tags = list(type = "string")), type = structure(logical(0), tags = list(type = "string")), exportConfig = structure(list(exportConfigType = structure(logical(0), tags = list(type = "string")), s3Destination = structure(list(bucket = structure(logical(0), tags = list(type = "string")), path = structure(logical(0), tags = list(type = "string")), packaging = structure(logical(0), tags = list(type = "string")), encryptionKey = structure(logical(0), tags = list(type = "string")), encryptionDisabled = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure"))), tags = list(type = "structure")), created = structure(logical(0), tags = list(type = "timestamp")), lastModified = structure(logical(0), tags = list(type = "timestamp")), tags = structure(list(structure(list(key = structure(logical(0), tags = list(type = "string")), value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), status = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$update_webhook_input <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(projectName = structure(logical(0), tags = list(type = "string")), branchFilter = structure(logical(0), tags = list(type = "string")), rotateSecret = structure(logical(0), tags = list(type = "boolean")), filterGroups = structure(list(structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), pattern = structure(logical(0), tags = list(type = "string")), excludeMatchedPattern = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "list")), buildType = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")) return(populate(args, shape)) } .codebuild$update_webhook_output <- function(...) { args <- c(as.list(environment()), list(...)) shape <- structure(list(webhook = structure(list(url = structure(logical(0), tags = list(type = "string")), payloadUrl = structure(logical(0), tags = list(type = "string")), secret = structure(logical(0), tags = list(type = "string")), branchFilter = structure(logical(0), tags = list(type = "string")), filterGroups = structure(list(structure(list(structure(list(type = structure(logical(0), tags = list(type = "string")), pattern = structure(logical(0), tags = list(type = "string")), excludeMatchedPattern = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "list")), buildType = structure(logical(0), tags = list(type = "string")), lastModifiedSecret = structure(logical(0), tags = list(type = "timestamp"))), tags = list(type = "structure"))), tags = list(type = "structure")) return(populate(args, shape)) }
observe({ req(length(DATA()) > 0) if (input$Settings.Color.Scheme != "Custom") { set_color_scheme(input$Settings.Color.Scheme, get_id(DATA()), NULL) } }) output$Settings.Color.Example <- downloadHandler( filename = function() { "Example_Colorfile" }, content = function(file) { write.csv2(get_color_scheme_dt(), file, row.names = F) } ) output$Settings.Color.Plot <- renderPlotly({ plot_color_example() }) plot_color_example <- function(){ curr_settings <- c(input$Settings.Color.Bg, input$Settings.Color.Grid, input$Settings.Color.Tick, input$Settings.Legend.Location, input$Settings.Font.Title, input$Settings.Font.Legend, input$Settings.Font.Label, input$Settings.Font.Tick, input$Settings.Color.Linewidth, input$Settings.Color.Markersize, input$IOHanalyzer.custom_legend_x, input$IOHanalyzer.custom_legend_y ) if (any(is.null(curr_settings))) return(NULL) if (length(DATA_RAW()) > 0) { algnames <- get_id(DATA_RAW()) } else algnames <- c("Alg 1", "Alg 2", "Alg 3", "Alg 4", "Alg 5") colors <- get_color_scheme(algnames) schemename <- input$Settings.Color.Scheme if (schemename == "Custom" && !is.null(input$Settings.Color.Upload)) { schemename <- paste0(schemename, ": ", input$Settings.Color.Upload$datapath) } x <- c(rep(1, length(algnames)),rep(2, length(algnames))) y <- seq_len(length(algnames)) dt <- data.table(ID = rep(algnames, 2), x, y) p <- plot_general_data(dt, 'x', 'y', 'line', show.legend = T, x_title = 'X-title', y_title = 'Y-title', plot_title = 'Plot Title') p } selected_color_congfig <- observe({ if (!is.null(input$Settings.Color.Upload)) { datapath <- input$Settings.Color.Upload$datapath tryCatch( expr = { set_color_scheme("Custom", path = datapath) }, error = function(e) { shinyjs::alert("File could not be read, please upload a file in the same format as the example.") } ) } }) observe({ input$Settings.General.Probs %>% strsplit(.,',') %>% .[[1]] %>% as.numeric %>% options("IOHanalyzer.quantiles" = .) }) observe({ options("IOHanalyzer.max_samples" = input$Settings.General.Max_samples) }) observe({ options("IOHanalyzer.backend" = input$Settings.General.Backend) }) observe({ options("IOHanalyzer.bgcolor" = input$Settings.Color.Bg) }) observe({ options("IOHanalyzer.gridcolor" = input$Settings.Color.Grid) }) observe({ options("IOHanalyzer.tickcolor" = input$Settings.Color.Tick) }) observe({ options("IOHanalyzer.linewidth" = input$Settings.Color.Linewidth) }) observe({ options("IOHanalyzer.markersize" = input$Settings.Color.Markersize) }) observe({ options("IOHanalyzer.figure_width" = input$Settings.Download.Width) }) observe({ options("IOHanalyzer.figure_height" = input$Settings.Download.Height) }) observe({ options("IOHanalyzer.custom_legend_x" = input$Settings.Legend.LocationX) }) observe({ options("IOHanalyzer.custom_legend_y" = input$Settings.Legend.LocationY) }) observe({ legend_loc <- input$Settings.Legend.Location if (legend_loc == "Outside, right") legend_loc_str <- "outside_right" else if (legend_loc == "Inside, right") legend_loc_str <- "inside_right" else if (legend_loc == "Inside, left") legend_loc_str <- "inside_left" else if (legend_loc == "Below") legend_loc_str <- "below" else if (legend_loc == "Custom") legend_loc_str <- "custom" options("IOHanalyzer.legend_location" = legend_loc_str) }) observe({ options("IOHanalyzer.tick_fontsize" = input$Settings.Font.Tick) }) observe({ options("IOHanalyzer.legend_fontsize" = input$Settings.Font.Legend) }) observe({ options("IOHanalyzer.title_fontsize" = input$Settings.Font.Title) }) observe({ options("IOHanalyzer.label_fontsize" = input$Settings.Font.Label) }) observe({ options("IOHanalyzer.precision" = input$Settings.General.Precision) }) observe({ req(input$Settings.ID.Variables) withProgress({ id_vars <- input$Settings.ID.Variables if (!setequal(id_vars,getOption('IOHanalyzer.ID_vars', c('algId')))) { options("IOHanalyzer.ID_vars" = input$Settings.ID.Variables) DataList$data <- change_id(DataList$data, input$Settings.ID.Variables) } if ('algId' %in% id_vars) shinyjs::hide(id = "overall_algid_box") else shinyjs::show(id = "overall_algid_box") }, message = "Processing IDs") }) observe({ if (input$Settings.Use_Funcname) { shinyjs::show(id = "overall_funcname_box") shinyjs::hide(id = "overall_funcid_box") options('IOHanalyzer.function_representation' = 'funcname') } else { shinyjs::hide(id = "overall_funcname_box") shinyjs::show(id = "overall_funcid_box") options('IOHanalyzer.function_representation' = 'funcId') } }) observe({ setting_preset <- input$Settings.Download.Preset if (setting_preset == "Default") { updateNumericInput(session, 'Settings.Download.Width', value = 1000) updateNumericInput(session, 'Settings.Download.Height', value = 1000) updateNumericInput(session, 'Settings.Font.Tick', value = 12) updateNumericInput(session, 'Settings.Font.Legend', value = 13) updateNumericInput(session, 'Settings.Font.Title', value = 16) updateNumericInput(session, 'Settings.Font.Label', value = 16) } else if (setting_preset == "Paper-1col") { updateNumericInput(session, 'Settings.Download.Width', value = 700) updateNumericInput(session, 'Settings.Download.Height', value = 400) updateNumericInput(session, 'Settings.Font.Tick', value = 9) updateNumericInput(session, 'Settings.Font.Legend', value = 10) updateNumericInput(session, 'Settings.Font.Title', value = 13) updateNumericInput(session, 'Settings.Font.Label', value = 13) } else if (setting_preset == "Paper-2col") { updateNumericInput(session, 'Settings.Download.Width', value = 900) updateNumericInput(session, 'Settings.Download.Height', value = 600) updateNumericInput(session, 'Settings.Font.Tick', value = 11) updateNumericInput(session, 'Settings.Font.Legend', value = 12) updateNumericInput(session, 'Settings.Font.Title', value = 16) updateNumericInput(session, 'Settings.Font.Label', value = 15) } }) output$Settings.Download <- downloadHandler( filename = "IOHanalyzer_settings.rds", content = function(file){ curr_opts <- options() IOH_opts <- curr_opts[grep(names(curr_opts), pattern = "IOH")] saveRDS(IOH_opts, file) }, contentType = "rds" ) observe({ if (!is.null(input$Settings.Upload)) { file <- input$Settings.Upload$datapath IOH_opts <- readRDS(file) options(IOH_opts[grep(names(IOH_opts), pattern = "IOH")]) } }) output$Settings.Plot.Download <- downloadHandler( filename = "Sample_plot.pdf", content = function(file) { save_plotly(plot_color_example(), file) }, contentType = 'image/pdf' )
library(tinytest) library(tiledb) isOldWindows <- Sys.info()[["sysname"]] == "Windows" && grepl('Windows Server 2008', osVersion) if (isOldWindows) exit_file("skip this file on old Windows releases") tiledb_ctx(limitTileDBCores()) ver <- tiledb_version() expect_equal(length(ver), 3) expect_equal(names(ver), c("major", "minor", "patch")) expect_true(ver[1] >= 1) expect_true(ver[2] >= 0) expect_true(ver[3] >= 0) config <- tiledb:::libtiledb_config() config <- tiledb:::libtiledb_config_set(config, "foo", "10") expect_equal(tiledb:::libtiledb_config_get(config, "foo"), c("foo" = "10")) params = c("foo" = "bar") config <- tiledb:::libtiledb_config(params) expect_equal(tiledb:::libtiledb_config_get(config, "foo"), c("foo" = "bar")) config <- tiledb:::libtiledb_config() expect_equal(unname(tiledb:::libtiledb_config_get(config, "don't exist")), NA_character_) params = c() default_config <- tiledb:::libtiledb_config() params_config <- tiledb:::libtiledb_config(params) expect_equal( tiledb:::libtiledb_config_get(default_config, "sm.tile_cache_size"), tiledb:::libtiledb_config_get(params_config, "sm.tile_cache_size") ) config <- tiledb:::libtiledb_config() config_vec <- tiledb:::libtiledb_config_vector(config) expect_true(is(config_vec, "character")) check <- c() for (n in names(config_vec)) { expect_equal(tiledb:::libtiledb_config_get(config, n), config_vec[n]) } ctx <- tiledb_ctx() expect_true(is(ctx@ptr, "externalptr")) ctx <- tiledb:::libtiledb_ctx() expect_true(is(ctx, "externalptr")) ctx <- tiledb_get_context() expect_true(is(ctx@ptr, "externalptr")) if (FALSE) { ctx <- tiledb_get_context() ctx_config <- tiledb:::libtiledb_ctx_config(ctx@ptr) default_config <- tiledb:::libtiledb_config() expect_equal(tiledb:::libtiledb_config_vector(ctx_config), tiledb:::libtiledb_config_vector(default_config)) } config <- tiledb:::libtiledb_config(c(foo = "bar")) ctx <- tiledb:::libtiledb_ctx(config) expect_equal(tiledb:::libtiledb_config_get(tiledb:::libtiledb_ctx_config(ctx), "foo"), c(foo = "bar")) ctx <- tiledb_get_context()@ptr expect_true(tiledb:::libtiledb_ctx_is_supported_fs(ctx, "file")) expect_true(is(tiledb:::libtiledb_ctx_is_supported_fs(ctx, "s3"), "logical")) expect_true(is(tiledb:::libtiledb_ctx_is_supported_fs(ctx, "hdfs"), "logical")) expect_error(tiledb:::libtiledb_ctx_is_supported_fs(ctx, "should error")) ctx <- tiledb_get_context()@ptr dim <- tiledb:::libtiledb_dim(ctx, "d1", "INT32", c(1L, 100L), 10L) expect_true(is(dim, "externalptr")) ctx <- tiledb_get_context()@ptr dim <- tiledb:::libtiledb_dim(ctx, "d1", "FLOAT64", c(1.0, 100.0), 10.0) expect_true(is(dim, "externalptr")) ctx <- tiledb_get_context()@ptr d1 <- tiledb:::libtiledb_dim(ctx, "d1", "INT32", c(1L, 100L), 10L) d2 <- tiledb:::libtiledb_dim(ctx, "d2", "INT32", c(1L, 100L), 10L) dom <- tiledb:::libtiledb_domain(ctx, c(d1, d2)) expect_true(is(dom, "externalptr")) ctx <- tiledb_get_context()@ptr d1 <- tiledb:::libtiledb_dim(ctx, "d1", "INT32", c(1L, 100L), 10L) d2 <- tiledb:::libtiledb_dim(ctx, "d2", "FLOAT64", c(1, 100), 10) dom <- tiledb:::libtiledb_domain(ctx, c(d1, d2)) expect_true(is(dom, "externalptr")) ctx <- tiledb_get_context()@ptr filter <- tiledb:::libtiledb_filter(ctx, "NONE") filter_list <- tiledb:::libtiledb_filter_list(ctx, c(filter)) attr <- tiledb:::libtiledb_attribute(ctx, "a1", "INT32", filter_list, 1, FALSE) expect_true(is(attr, "externalptr")) ctx <- tiledb_get_context()@ptr filter <- tiledb:::libtiledb_filter(ctx, "NONE") filter_list <- tiledb:::libtiledb_filter_list(ctx, c(filter)) attr <- tiledb:::libtiledb_attribute(ctx, "a1", "FLOAT64", filter_list, 1, FALSE) expect_true(is(attr, "externalptr")) ctx <- tiledb_get_context()@ptr dim <- tiledb:::libtiledb_dim(ctx, "d1", "INT32", c(1L, 3L), 3L) dom <- tiledb:::libtiledb_domain(ctx, c(dim)) filter <- tiledb:::libtiledb_filter(ctx, "GZIP") tiledb:::libtiledb_filter_set_option(filter, "COMPRESSION_LEVEL", 5) filter_list <- tiledb:::libtiledb_filter_list(ctx, c(filter)) att <- tiledb:::libtiledb_attribute(ctx, "a1", "FLOAT64", filter_list, 1, FALSE) sch <- tiledb:::libtiledb_array_schema(ctx, dom, c(att), cell_order = "COL_MAJOR", tile_order = "COL_MAJOR", sparse = FALSE) expect_true(is(sch, "externalptr")) dir.create(tmp <- tempfile()) ctx <- tiledb_get_context()@ptr dim <- tiledb:::libtiledb_dim(ctx, "d1", "INT32", c(1L, 3L), 3L) dom <- tiledb:::libtiledb_domain(ctx, c(dim)) filter <- tiledb:::libtiledb_filter(ctx, "NONE") filter_list <- tiledb:::libtiledb_filter_list(ctx, c(filter)) att <- tiledb:::libtiledb_attribute(ctx, "a1", "FLOAT64", filter_list, 1, FALSE) sch <- tiledb:::libtiledb_array_schema(ctx, dom, c(att), cell_order = "COL_MAJOR", tile_order = "COL_MAJOR", sparse = FALSE) pth <- paste(tmp, "test_array", sep = "/") uri <- tiledb:::libtiledb_array_create(pth, sch) expect_true(dir.exists(pth)) unlink(tmp, recursive = TRUE) dir.create(tmp <- tempfile()) ctx <- tiledb_get_context()@ptr dim <- tiledb:::libtiledb_dim(ctx, "d1", "INT32", c(1L, 3L), 3L) dom <- tiledb:::libtiledb_domain(ctx, c(dim)) filter <- tiledb:::libtiledb_filter(ctx, "NONE") filter_list <- tiledb:::libtiledb_filter_list(ctx, c(filter)) att <- tiledb:::libtiledb_attribute(ctx, "a1", "FLOAT64", filter_list, 1, FALSE) sch <- tiledb:::libtiledb_array_schema(ctx, dom, c(att), cell_order = "COL_MAJOR", tile_order = "COL_MAJOR", sparse = FALSE) pth <- paste(tmp, "test_dense_read_write", sep = "/") uri <- tiledb:::libtiledb_array_create(pth, sch) dat <- c(3, 2, 1) arr <- tiledb:::libtiledb_array_open(ctx, uri, "WRITE") qry <- tiledb:::libtiledb_query(ctx, arr, "WRITE") qry <- tiledb:::libtiledb_query_set_buffer(qry, "a1", dat) qry <- tiledb:::libtiledb_query_submit(qry) tiledb:::libtiledb_array_close(arr) expect_true(is(qry, "externalptr")) res <- c(0, 0, 0) arr <- tiledb:::libtiledb_array_open(ctx, uri, "READ") qry2 <- tiledb:::libtiledb_query(ctx, arr, "READ") qry2 <- tiledb:::libtiledb_query_set_buffer(qry2, "a1", res) tiledb:::libtiledb_array_close(arr) unlink(tmp, recursive = TRUE) dir.create(tmp <- tempfile()) ctx <- tiledb_get_context()@ptr dim <- tiledb:::libtiledb_dim(ctx, "d1", "INT32", c(1L, 3L), 3L) dom <- tiledb:::libtiledb_domain(ctx, c(dim)) filter <- tiledb:::libtiledb_filter(ctx, "NONE") filter_list <- tiledb:::libtiledb_filter_list(ctx, c(filter)) att <- tiledb:::libtiledb_attribute(ctx, "a1", "FLOAT64", filter_list, 1, FALSE) sch <- tiledb:::libtiledb_array_schema(ctx, dom, c(att), cell_order = "COL_MAJOR", tile_order = "COL_MAJOR", sparse = FALSE) pth <- paste(tmp, "test_dense_read_write", sep = "/") uri <- tiledb:::libtiledb_array_create(pth, sch) dat <- c(3, 2, 1) arr <- tiledb:::libtiledb_array_open(ctx, uri, "WRITE") qry <- tiledb:::libtiledb_query(ctx, arr, "WRITE") qry <- tiledb:::libtiledb_query_set_buffer(qry, "a1", dat) qry <- tiledb:::libtiledb_query_submit(qry) tiledb:::libtiledb_array_close(arr) expect_true(is(qry, "externalptr")) res <- c(0, 0) sub <- c(1L, 2L) arr <- tiledb:::libtiledb_array_open(ctx, uri, "READ") qry2 <- tiledb:::libtiledb_query(ctx, arr, "READ") qry2 <- tiledb:::libtiledb_query_set_subarray(qry2, sub) qry2 <- tiledb:::libtiledb_query_set_buffer(qry2, "a1", res) qry2 <- tiledb:::libtiledb_query_submit(qry2) tiledb:::libtiledb_array_close(arr) expect_equal(res, dat[sub]) unlink(tmp, recursive = TRUE) ctx <- tiledb_get_context()@ptr vfs <- tiledb:::libtiledb_vfs(ctx) expect_true(is(vfs, "externalptr")) config <- tiledb:::libtiledb_config(c(foo="bar")) vfs <- tiledb:::libtiledb_vfs(ctx, config) expect_true(is(vfs, "externalptr")) dir.create(tmp <- tempfile()) ctx <- tiledb_get_context()@ptr vfs <- tiledb:::libtiledb_vfs(ctx) expect_true(tiledb:::libtiledb_vfs_is_dir(vfs, tmp)) expect_false(tiledb:::libtiledb_vfs_is_dir(vfs, "i don't exist")) test_file_path <- paste("file:/", tmp, "test_file", sep = "/") test_file <- file(test_file_path, "wb") writeChar(c("foo", "bar", "baz"), test_file) close(test_file) if(.Platform$OS.type != "windows") { expect_true(tiledb:::libtiledb_vfs_is_file(vfs, test_file_path)) } expect_false(tiledb:::libtiledb_vfs_is_file(vfs, tmp)) unlink(tmp, recursive = TRUE)
test_that("Output class is same as input class", { df <- qualtrics_text %>% mark_duplicates(quiet = TRUE) %>% mark_duration(min_duration = 100, quiet = TRUE) expect_s3_class(unite_exclusions(df), class(df)) }) test_that("Data frames are correct size", { skip_on_cran() df <- qualtrics_text %>% mark_duplicates(quiet = TRUE) %>% mark_duration(min_duration = 100, quiet = TRUE) %>% mark_ip(quiet = TRUE) %>% mark_location(quiet = TRUE) %>% mark_preview(quiet = TRUE) %>% mark_progress(quiet = TRUE) %>% mark_resolution(quiet = TRUE) expect_true(ncol(unite_exclusions(df)) == 17) expect_true(ncol(unite_exclusions(df, exclusion_types = c("duplicates", "duration", "ip") )) == 21) }) test_that("Error displayed when exclusion columns not present", { suppressMessages(expect_error(unite_exclusions(qualtrics_numeric))) })
A_sampling<-function(Y, C, A_old, X, base_line, C_prior, sigma_noise, sigma_A, sigma_baseline, sigma_X){ Num_genes=nrow(Y) Num_samples=ncol(Y) Num_TFs=ncol(C_prior) A_new=matrix(0, nrow=Num_genes, ncol=Num_TFs) for (n in 1:Num_genes){ for (t2 in 1:Num_TFs){ temp=matrix(0, nrow=1, ncol=Num_samples) for (m in 1:Num_samples){ for (t1 in 1:Num_TFs){ temp[m]=temp[m]+A_old[n,t1]*C[n,t1]*X[t1,m] } } if (C[n,t2]==1){ temp_c=temp-A_old[n,t2]*X[t2,m] vairance_A=Num_samples*sigma_A*sigma_noise/(sum(X[t2,]^2)*sigma_A+Num_samples*sigma_noise) mean_A=sum((Y[n,]-temp_c-base_line[n])*X[t2,])/sigma_noise/Num_samples*vairance_A A_temp=rnorm(1, mean=mean_A, sd=sqrt(vairance_A)) A_new[n,t2] = A_temp }else A_new[n,t2]=0 } } return(A_new) }
recur_on_ymonth <- function(x, ymonth) { validate_rrule(x, "x") ymonth <- month_normalize(ymonth) old <- get_rule(x, "ymonth") new <- vec_cast(ymonth, integer(), x_arg = "ymonth") if (any(new > 12 | new < 1)) { abort("`ymonth` can only take values in [1, 12].") } new <- union(old, new) new <- unique(new) new <- sort(new) tweak_rrule(x, ymonth = new) } month_normalize <- function(x) { if (!is.character(x)) { return(x) } x <- tolower(x) where <- month_match(x) misses <- is.na(where) if (any(misses)) { abort("A character `x` must be a month name or abbreviation.") } out <- month_int()[where] out <- unique(out) out } month_match <- function(x) { vec_match(x, month_name()) } month_name <- function() { c( tolower(month.name), tolower(month.abb), "sept" ) } month_int <- function() { c( 1:12, 1:12, 9L ) }
msaenet.tune.glmnet <- function( x, y, family, alphas, tune, nfolds, rule, ebic.gamma, lower.limits, upper.limits, seed, parallel, ...) { if (tune == "cv") { if (!parallel) { model.list <- vector("list", length(alphas)) for (i in 1L:length(alphas)) { set.seed(seed) model.list[[i]] <- cv.glmnet( x = x, y = y, family = family, nfolds = nfolds, alpha = alphas[i], lower.limits = lower.limits, upper.limits = upper.limits, ... ) } } else { model.list <- foreach(alphas = alphas) %dopar% { set.seed(seed) cv.glmnet( x = x, y = y, family = family, nfolds = nfolds, alpha = alphas, lower.limits = lower.limits, upper.limits = upper.limits, ... ) } } errors <- unlist(lapply(model.list, function(x) min(sqrt(x$"cvm")))) errors.min.idx <- which.min(errors) best.model <- model.list[[errors.min.idx]] best.alpha <- alphas[errors.min.idx] if (rule == "lambda.min") best.lambda <- best.model$"lambda.min" if (rule == "lambda.1se") best.lambda <- best.model$"lambda.1se" step.criterion <- errors[errors.min.idx] } else { if (!parallel) { model.list <- vector("list", length(alphas)) for (i in 1L:length(alphas)) { set.seed(seed) model.list[[i]] <- glmnet( x = x, y = y, family = family, alpha = alphas[i], lower.limits = lower.limits, upper.limits = upper.limits, ... ) } } else { model.list <- foreach(alphas = alphas) %dopar% { set.seed(seed) glmnet( x = x, y = y, family = family, alpha = alphas, lower.limits = lower.limits, upper.limits = upper.limits, ... ) } } if (tune == "aic") { ics.list <- mapply( .aic, deviance = lapply(model.list, .deviance), df = lapply(model.list, .df), SIMPLIFY = FALSE ) } if (tune == "bic") { ics.list <- mapply( .bic, deviance = lapply(model.list, .deviance), df = lapply(model.list, .df), nobs = lapply(model.list, .nobs), SIMPLIFY = FALSE ) } if (tune == "ebic") { ics.list <- mapply( .ebic, deviance = lapply(model.list, .deviance), df = lapply(model.list, .df), nobs = lapply(model.list, .nobs), nvar = lapply(model.list, .nvar), gamma = ebic.gamma, SIMPLIFY = FALSE ) } ics <- sapply(ics.list, function(x) min(x)) ics.min.idx <- which.min(ics) best.model <- model.list[[ics.min.idx]] best.alpha <- alphas[ics.min.idx] best.ic.min.idx <- which.min(ics.list[[ics.min.idx]]) best.lambda <- best.model$"lambda"[[best.ic.min.idx]] step.criterion <- ics.list[[ics.min.idx]][[best.ic.min.idx]] } list( "best.model" = best.model, "best.alpha" = best.alpha, "best.lambda" = best.lambda, "step.criterion" = step.criterion ) } msaenet.tune.nsteps.glmnet <- function( model.list, tune.nsteps, ebic.gamma.nsteps) { nmods <- length(model.list) if (tune.nsteps == "max") { ics <- NULL best.step <- nmods } else { if (tune.nsteps == "aic") { ics <- .aic( deviance = sapply(model.list, .deviance), df = sapply(model.list, .df) ) } if (tune.nsteps == "bic") { ics <- .bic( deviance = sapply(model.list, .deviance), df = sapply(model.list, .df), nobs = sapply(model.list, .nobs) ) } if (tune.nsteps == "ebic") { ics <- .ebic( deviance = sapply(model.list, .deviance), df = sapply(model.list, .df), nobs = sapply(model.list, .nobs), nvar = sapply(model.list, .nvar), gamma = ebic.gamma.nsteps ) } best.step <- which.min(ics) } list("best.step" = best.step, "ics" = ics) }
context("Style Parsing") test_that("parsing border xml", { wb <- loadWorkbook(file = system.file("loadExample.xlsx", package = "openxlsx")) styles <- getStyles(wb = wb) expected_borders <- list(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "medium", "medium", "medium", "medium", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "thin", NULL, "thin", "thin", NULL, "thin", "thin", "thin", "thin", "thin", "thin", "thin", NULL, "thin", "thin", "medium", "medium", "medium", "medium", "thin", "medium", "medium", "thin", NULL, "medium", "medium", "medium", "thin", "thin", "medium", "medium", "thin", "thin", "thick", NULL, "thick", "thick", "thick", NULL, NULL, NULL, NULL, NULL, "medium", "medium", NULL, "medium", "mediumDashed", "mediumDashed", "mediumDashed", NULL, NULL, NULL, NULL, NULL, NULL) expect_equal(expected_borders, sapply(styles, "[[", "borderBottom")) expected_borders <- list(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "thin", "thin", "thin", NULL, NULL, NULL, NULL, "medium", NULL, NULL, NULL, NULL, NULL, "thin", NULL, "thin", "thick", NULL, "medium", "thin", "thin", "thin", "thin", "thick", "thick", "thin", "thin", "thin", "medium", "medium", "thin", "thick", "thick", "medium", "thin", "thick", "thick", "medium", "thin", "thin", "medium", "thin", "thin", "thin", "medium", "medium", "medium", NULL, NULL, NULL, NULL, NULL, NULL, "mediumDashed", "mediumDashed", "mediumDashed", NULL, NULL, NULL, NULL, NULL, NULL) expect_equal(expected_borders, sapply(styles, "[[", "borderTop")) expected_borders <- list(NULL, NULL, NULL, NULL, NULL, NULL, "medium", NULL, "medium", NULL, NULL, NULL, NULL, NULL, NULL, "thin", NULL, NULL, "thin", NULL, NULL, "thin", "medium", NULL, NULL, NULL, NULL, "thin", "thin", "thin", NULL, "thin", NULL, NULL, NULL, "thin", "medium", "thin", "thin", "thin", "thin", "medium", "thin", "thin", NULL, "thin", "thick", "thin", "thick", "thick", "thin", "thin", "thin", "thin", "thick", NULL, "thin", "thin", "thin", "medium", NULL, NULL, "medium", NULL, "medium", NULL, "medium", NULL, "mediumDashed", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) expect_equal(expected_borders, sapply(styles, "[[", "borderLeft")) expected_borders <- list(NULL, NULL, NULL, NULL, NULL, "medium", NULL, "medium", NULL, NULL, NULL, "medium", NULL, NULL, NULL, NULL, NULL, "thin", NULL, NULL, "thin", NULL, NULL, NULL, "thin", NULL, "thin", NULL, "thin", "thin", "thin", "thin", "thick", NULL, "thick", "medium", "thin", "thin", "thin", "thin", "medium", "thin", "thin", "medium", NULL, "medium", "thin", "thin", "medium", "medium", "thin", "thick", "medium", "medium", "thin", "medium", "thin", NULL, "thick", NULL, NULL, "medium", NULL, "medium", NULL, NULL, NULL, "medium", NULL, NULL, "mediumDashed", NULL, NULL, NULL, NULL, NULL, NULL) expect_equal(expected_borders, sapply(styles, "[[", "borderRight")) expected_borders <- list(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, structure(list( indexed = "64"), .Names = "indexed"), structure(list(indexed = "64"), .Names = "indexed"), structure(list(indexed = "64"), .Names = "indexed"), structure(list( indexed = "64"), .Names = "indexed"), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, structure(list(theme = "6"), .Names = "theme"), NULL, structure(list(theme = "6"), .Names = "theme"), structure(list( theme = "6"), .Names = "theme"), NULL, structure(list( indexed = "64"), .Names = "indexed"), structure(list( indexed = "64"), .Names = "indexed"), structure(list( indexed = "64"), .Names = "indexed"), structure(list( indexed = "64"), .Names = "indexed"), structure(list( indexed = "64"), .Names = "indexed"), structure(list( indexed = "64"), .Names = "indexed"), structure(list( indexed = "64"), .Names = "indexed"), NULL, structure(list( indexed = "64"), .Names = "indexed"), structure(list( indexed = "64"), .Names = "indexed"), structure(list( theme = "3"), .Names = "theme"), structure(list(theme = "3"), .Names = "theme"), structure(list(theme = "3"), .Names = "theme"), structure(list( theme = "6"), .Names = "theme"), structure(list(indexed = "64"), .Names = "indexed"), structure(list(theme = "6"), .Names = "theme"), structure(list( theme = "6"), .Names = "theme"), structure(list(indexed = "64"), .Names = "indexed"), NULL, structure(list(theme = "6"), .Names = "theme"), structure(list( theme = "7\" tint=\"-0.249977111117893"), .Names = "theme"), structure(list(theme = "7\" tint=\"-0.249977111117893"), .Names = "theme"), structure(list(indexed = "64"), .Names = "indexed"), structure(list( indexed = "64"), .Names = "indexed"), structure(list( theme = "9\" tint=\"-0.249977111117893"), .Names = "theme"), structure(list(theme = "9\" tint=\"-0.249977111117893"), .Names = "theme"), structure(list(indexed = "64"), .Names = "indexed"), structure(list( indexed = "64"), .Names = "indexed"), structure(list( theme = "5\" tint=\"-0.249977111117893"), .Names = "theme"), NULL, structure(list(theme = "5\" tint=\"-0.249977111117893"), .Names = "theme"), structure(list(theme = "5\" tint=\"-0.249977111117893"), .Names = "theme"), structure(list(theme = "5\" tint=\"-0.249977111117893"), .Names = "theme"), NULL, NULL, NULL, NULL, NULL, structure("9\" tint=\"-0.249977111117893", .Names = "theme"), structure("9\" tint=\"-0.249977111117893", .Names = "theme"), NULL, structure("9\" tint=\"-0.249977111117893", .Names = "theme"), structure("9\" tint=\"-0.249977111117893", .Names = "theme"), structure("9\" tint=\"-0.249977111117893", .Names = "theme"), structure("9\" tint=\"-0.249977111117893", .Names = "theme"), NULL, NULL, NULL, NULL, NULL, NULL) expect_equal(expected_borders, sapply(styles, "[[", "borderBottomColour")) expected_borders <- list(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, structure(list(theme = "6"), .Names = "theme"), structure(list(theme = "6"), .Names = "theme"), structure(list( theme = "6"), .Names = "theme"), NULL, NULL, NULL, NULL, structure(list(indexed = "64"), .Names = "indexed"), NULL, NULL, NULL, NULL, NULL, structure(list(indexed = "64"), .Names = "indexed"), NULL, structure(list(indexed = "64"), .Names = "indexed"), structure(list(theme = "5\" tint=\"-0.249977111117893"), .Names = "theme"), NULL, structure(list(indexed = "64"), .Names = "indexed"), structure(list(indexed = "64"), .Names = "indexed"), structure(list( indexed = "64"), .Names = "indexed"), structure(list( indexed = "64"), .Names = "indexed"), structure(list( indexed = "64"), .Names = "indexed"), structure(list( theme = "5\" tint=\"-0.249977111117893"), .Names = "theme"), structure(list(theme = "5\" tint=\"-0.249977111117893"), .Names = "theme"), structure(list(indexed = "64"), .Names = "indexed"), structure(list( indexed = "64"), .Names = "indexed"), structure(list( indexed = "64"), .Names = "indexed"), structure(list( theme = "6"), .Names = "theme"), structure(list(indexed = "64"), .Names = "indexed"), structure(list(indexed = "64"), .Names = "indexed"), structure(list( theme = "5\" tint=\"-0.249977111117893"), .Names = "theme"), structure(list(theme = "5\" tint=\"-0.249977111117893"), .Names = "theme"), structure(list(theme = "7\" tint=\"-0.249977111117893"), .Names = "theme"), structure(list(indexed = "64"), .Names = "indexed"), structure(list( theme = "5\" tint=\"-0.249977111117893"), .Names = "theme"), structure(list(theme = "5\" tint=\"-0.249977111117893"), .Names = "theme"), structure(list(theme = "9\" tint=\"-0.249977111117893"), .Names = "theme"), structure(list(indexed = "64"), .Names = "indexed"), structure(list( indexed = "64"), .Names = "indexed"), structure(list( indexed = "64"), .Names = "indexed"), structure(list( indexed = "64"), .Names = "indexed"), structure(list( indexed = "64"), .Names = "indexed"), structure(list( indexed = "64"), .Names = "indexed"), structure("9\" tint=\"-0.249977111117893", .Names = "theme"), structure("9\" tint=\"-0.249977111117893", .Names = "theme"), structure("9\" tint=\"-0.249977111117893", .Names = "theme"), NULL, NULL, NULL, NULL, NULL, NULL, structure("9\" tint=\"-0.249977111117893", .Names = "theme"), structure("9\" tint=\"-0.249977111117893", .Names = "theme"), structure("9\" tint=\"-0.249977111117893", .Names = "theme"), NULL, NULL, NULL, NULL, NULL, NULL) expect_equal(expected_borders, sapply(styles, "[[", "borderTopColour")) expected_borders <- list(NULL, NULL, NULL, NULL, NULL, NULL, structure(list(indexed = "64"), .Names = "indexed"), NULL, structure(list(indexed = "64"), .Names = "indexed"), NULL, NULL, NULL, NULL, NULL, NULL, structure(list(theme = "6"), .Names = "theme"), NULL, NULL, structure(list(theme = "6"), .Names = "theme"), NULL, NULL, structure(list(theme = "6"), .Names = "theme"), structure(list(indexed = "64"), .Names = "indexed"), NULL, NULL, NULL, NULL, structure(list(indexed = "64"), .Names = "indexed"), structure(list(indexed = "64"), .Names = "indexed"), structure(list( indexed = "64"), .Names = "indexed"), NULL, structure(list( indexed = "64"), .Names = "indexed"), NULL, NULL, NULL, structure(list(indexed = "64"), .Names = "indexed"), structure(list( theme = "3"), .Names = "theme"), structure(list(indexed = "64"), .Names = "indexed"), structure(list(indexed = "64"), .Names = "indexed"), structure(list( indexed = "64"), .Names = "indexed"), structure(list( indexed = "64"), .Names = "indexed"), structure(list( theme = "6"), .Names = "theme"), structure(list(indexed = "64"), .Names = "indexed"), structure(list(indexed = "64"), .Names = "indexed"), NULL, structure(list(indexed = "64"), .Names = "indexed"), structure(list( theme = "5\" tint=\"-0.249977111117893"), .Names = "theme"), structure(list(indexed = "64"), .Names = "indexed"), structure(list( theme = "5\" tint=\"-0.249977111117893"), .Names = "theme"), structure(list(theme = "5\" tint=\"-0.249977111117893"), .Names = "theme"), structure(list(indexed = "64"), .Names = "indexed"), structure(list( indexed = "64"), .Names = "indexed"), structure(list( indexed = "64"), .Names = "indexed"), structure(list( indexed = "64"), .Names = "indexed"), structure(list( theme = "5\" tint=\"-0.249977111117893"), .Names = "theme"), NULL, structure(list(indexed = "64"), .Names = "indexed"), structure(list(indexed = "64"), .Names = "indexed"), structure(list( indexed = "64"), .Names = "indexed"), structure("9\" tint=\"-0.249977111117893", .Names = "theme"), NULL, NULL, structure("9\" tint=\"-0.249977111117893", .Names = "theme"), NULL, structure("9\" tint=\"-0.249977111117893", .Names = "theme"), NULL, structure(list(indexed = "64"), .Names = "indexed"), NULL, structure("9\" tint=\"-0.249977111117893", .Names = "theme"), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) expect_equal(expected_borders, sapply(styles, "[[", "borderLeftColour")) expected_borders <- list(NULL, NULL, NULL, NULL, NULL, structure(list(indexed = "64"), .Names = "indexed"), NULL, structure(list(indexed = "64"), .Names = "indexed"), NULL, NULL, NULL, structure(list(indexed = "64"), .Names = "indexed"), NULL, NULL, NULL, NULL, NULL, structure(list(theme = "6"), .Names = "theme"), NULL, NULL, structure(list(theme = "6"), .Names = "theme"), NULL, NULL, NULL, structure(list(theme = "6"), .Names = "theme"), NULL, structure(list(indexed = "64"), .Names = "indexed"), NULL, structure(list(indexed = "64"), .Names = "indexed"), structure(list(indexed = "64"), .Names = "indexed"), structure(list( indexed = "64"), .Names = "indexed"), structure(list( indexed = "64"), .Names = "indexed"), structure(list( theme = "5\" tint=\"-0.249977111117893"), .Names = "theme"), NULL, structure(list(theme = "5\" tint=\"-0.249977111117893"), .Names = "theme"), structure(list(theme = "3"), .Names = "theme"), structure(list( indexed = "64"), .Names = "indexed"), structure(list( indexed = "64"), .Names = "indexed"), structure(list( indexed = "64"), .Names = "indexed"), structure(list( indexed = "64"), .Names = "indexed"), structure(list( theme = "6"), .Names = "theme"), structure(list(indexed = "64"), .Names = "indexed"), structure(list(indexed = "64"), .Names = "indexed"), structure(list( theme = "6"), .Names = "theme"), NULL, structure(list( theme = "6"), .Names = "theme"), structure(list(indexed = "64"), .Names = "indexed"), structure(list(indexed = "64"), .Names = "indexed"), structure(list( theme = "7\" tint=\"-0.249977111117893"), .Names = "theme"), structure(list(theme = "7\" tint=\"-0.249977111117893"), .Names = "theme"), structure(list(indexed = "64"), .Names = "indexed"), structure(list( theme = "5\" tint=\"-0.249977111117893"), .Names = "theme"), structure(list(theme = "9\" tint=\"-0.249977111117893"), .Names = "theme"), structure(list(theme = "9\" tint=\"-0.249977111117893"), .Names = "theme"), structure(list(indexed = "64"), .Names = "indexed"), structure(list( indexed = "64"), .Names = "indexed"), structure(list( indexed = "64"), .Names = "indexed"), NULL, structure(list( theme = "5\" tint=\"-0.249977111117893"), .Names = "theme"), NULL, NULL, structure("9\" tint=\"-0.249977111117893", .Names = "theme"), NULL, structure("9\" tint=\"-0.249977111117893", .Names = "theme"), NULL, NULL, NULL, structure("9\" tint=\"-0.249977111117893", .Names = "theme"), NULL, NULL, structure("9\" tint=\"-0.249977111117893", .Names = "theme"), NULL, NULL, NULL, NULL, NULL, NULL) expect_equal(expected_borders, sapply(styles, "[[", "borderRightColour")) })
`rescale.symcoca` <- function(object, choices = NULL, display = c("species", "sites"), ...) { if (is.null(choices)) { choices <- seq_len(object$n.axes) } display <- match.arg(display, several.ok = TRUE) ev <- eigenvals(object, choices = choices) lc <- length(choices) lambda4 <- diag(sqrt(sqrt(ev)), nrow = lc, ncol = lc) colnames(lambda4) <- rownames(lambda4) <- names(ev) out <- list() if ("species" %in% display) { out$species <- list(Y = object$scores$species$Y[, choices, drop = FALSE] %*% lambda4, X = object$scores$species$X[, choices, drop = FALSE] %*% lambda4) } if ("sites" %in% display) { out$sites <- list(Y = object$scores$site$Y[, choices, drop = FALSE] %*% lambda4, X = object$scores$site$X[, choices, drop = FALSE] %*% lambda4) } if (length(out) == 1L) { out <- out[[1L]] } out }