code
stringlengths
1
13.8M
vpc_cens <- function(sim = NULL, obs = NULL, psn_folder = NULL, bins = "jenks", n_bins = 8, bin_mid = "mean", obs_cols = NULL, sim_cols = NULL, software...
PV_pre_triang_dis=function(data,years=10){ app=rep(NA,years) for(i in 1:years) app[i]=triangular_moments_dis_U(data,i) PV=1+sum(app[1:years-1]) return(PV) }
do.dne <- function(X, label, ndim=2, numk=max(ceiling(nrow(X)/10),2), preprocess=c("center","scale","cscale","decorrelate","whiten")){ aux.typecheck(X) n = nrow(X) p = ncol(X) ndim = as.integer(ndim) if (!check_ndim(ndim,p)){stop("* do.dne : 'ndim' is a positive integer in [1, ...
structure <- function (.Data, ...) { if(is.null(.Data)) warning("Calling 'structure(NULL, *)' is deprecated, as NULL cannot have attributes.\n Consider 'structure(list(), *)' instead.") attrib <- list(...) if(length(attrib)) { specials <- c(".Dim", ".Dimnames", ".Names", ".Tsp", "....
library(bmp) posey <- c(30, 167, 332, 457, 822, 1016, 1199, 1437, 1621, 1770, 1924, 2101, 2251, 2442, 2594, 2757, 2918, 3072, 3205, 3356, 3526, 3685, 4068, 4217) susac <- c(751, 1286, 1485, 1666, 2030, 2187) v <- list.files("buster_posey_catching/") v <- v[order(as.numeric(unlist(lapply(strsplit(v, split="i"), "[[", 1)...
QA_Results <- data.table::CJ( Group = c(0, 1, 2, 3), xregs = c(0, 1, 2, 3), Trans = c(TRUE, FALSE), Training = "Failure", Forecast = "Failure" ) for (run in seq_len(QA_Results[, .N])) { if (QA_Results[run, Group] == 0) { groupvars <- NULL ModelData <- data.table::fread(file = file.path("C:/Users/...
catEffectBootAdaptor<-function (df, index, testFnc = sumSqCat, useResp = TRUE, ...) { if (useResp) respVal <- df$resp else respVal <- df$bkg testFnc(respVal[index], df$cat, ...) }
count_levels_num <- function(x) { .Call('_inspectdf_count_levels_num', PACKAGE = 'inspectdf', x) } count_levels_char <- function(x) { .Call('_inspectdf_count_levels_char', PACKAGE = 'inspectdf', x) } na_numeric <- function(x) { .Call('_inspectdf_na_numeric', PACKAGE = 'inspectdf', x) } na_character <- funct...
T <- 50 m <- 10 P <- 5 H <- 2 N_min <- 20 X <- rnorm(T) mspe <- MSPE(X, m1 = T - m + 1, m2 = T, P = P, H = H, N = c(0, N_min:(T-m-H))) N <- mspe$N M <- mspe$mspe h <- 1 plot(mspe, h, N_min = N_min, legend = (h == 1)) idx1_s <- which(M[h, , N == 0] == min(M[h, , N == 0]), arr.ind = TRUE)[1] abline(h = M[h, idx1_s, N == ...
bhl_getunpublisheditems <- function(...) { .Defunct(package = "rbhl", msg = "API method removed") }
if (requiet("testthat") && requiet("insight") && requiet("robustbase")) { data(mtcars) m1 <- lmrob(mpg ~ gear + wt + cyl, data = mtcars) test_that("model_info", { expect_true(model_info(m1)$is_linear) }) test_that("find_predictors", { expect_identical(find_predictors(m1), list(conditional = c("gea...
fit_clutter <- function(df, age, dh, basal_area, volume, site, plot, .groups=NA, model = "full", keep_model = FALSE){ basal_area2<-basal_area1<-I1<-I2<-volume2<-.<-Reg<-NULL if( missing(df) ){ stop("df not set", call. = F) }else if(!is.data.frame(df)){ stop("df must be a dataframe", call.=F) ...
wait_slurm <- function(x, ...) UseMethod("wait_slurm") wait_slurm.slurm_job <- function(x, ...) { wait_slurm.integer(get_job_id(x), ...) } wait_slurm.integer <- function(x, timeout = -1, freq = 0.1, force = TRUE, ...) { if (opts_slurmR$get_debug()) { warning("waiting is not available in debug mode.", call. =...
test_that("compare state works correctly", { loc <- tempfile("watcher") dir.create(loc) empty <- dir_state(loc) expect_equal(length(empty), 0) file.create(file.path(loc, "test-1.txt")) one <- dir_state(loc) expect_equal(length(one), 1) expect_equal(basename(names(one)), "test-1.txt") diff <- compare_s...
AutoLightGBMClassifier <- function( data = NULL, TrainOnFull = FALSE, ValidationData = NULL, TestData = NULL, TargetColumnName = NULL, ...
.build_client <- function(api, encode, version = NULL, progress = NULL, pat = getOption("osfr.pat")) { api <- match.arg(api, c("osf", "wb")) encode <- match.arg(encode, c("form", "multipart", "json", "raw")) server <- Sys.getenv("OSF_SERVER") url <- switch(api, ...
BLOSUM62<-function(seqs,label=c(),outFormat="mat",outputFileDist=""){ path.pack=system.file("extdata",package="ftrCOOL") if(length(seqs)==1&&file.exists(seqs)){ seqs<-fa.read(seqs,alphabet="aa") seqs_Lab<-alphabetCheck(seqs,alphabet = "aa",label) seqs<-seqs_Lab[[1]] label<-seqs_Lab[[2]] } else i...
list2matrix.bas <- function(x, what, which.models = NULL) { namesx <- x$namesx if (is.null(which.models)) which.models <- 1:x$n.models listobj <- x[[what]][which.models] which <- x$which[which.models] n.models <- length(which.models) p <- length(namesx) mat <- matrix(0, nrow = n.models, ncol = p) for (i...
context("elevation utils") testthat::skip_on_cran() raster_poa <- system.file("extdata/poa/poa_elevation.tif", package = "r5r") data_path <- system.file("extdata/poa", package = "r5r") r5r_core <- setup_r5(data_path = data_path, temp_dir = TRUE) test_that("tobler_hiking", { expect_error( tobler_hiking('bananas') ) ...
bbase.os <- function(x, K, bdeg = 3, eps = 1e-5, intercept = TRUE) { B <- bs(x, degree = bdeg, df = K + bdeg, intercept = intercept) B }
tcplot <- function (data, u.range, cmax = FALSE, r = 1, ulow = -Inf, rlow = 1, nt = 25, which = 1:npar, conf = 0.95, lty = 1, lwd = 1, type = "b", cilty = 1, ask = nb.fig < length(which) && dev.interactive(), ...){ n <- length(data) data <- sort(data) if (missing(u.range)) { u.range...
library(plyr) suppressPackageStartupMessages(library(dplyr)) library(ggplot2) library(readr) gap_dat <- read_tsv("05_gap-merged-with-china-1952.tsv") %>% mutate(country = factor(country), continent = factor(continent)) gap_dat %>% str() gap_dat %>% sapply(function(x) x %>% is.na() %>% sum()) gap_dat$year...
"sdtm_ae" "sdtm_cm" "sdtm_dm" "sdtm_ds" "sdtm_ex" "sdtm_lb" "sdtm_mh" "sdtm_qs" "sdtm_relrec" "sdtm_sc" "sdtm_se" "sdtm_suppae" "sdtm_suppdm" "sdtm_suppds" "sdtm_supplb" "sdtm_sv" "sdtm_ta" "sdtm_te" "sdtm_ti" "sdtm_ts" "sdtm_tv" "sdtm_vs"
tree_add_dates <- function(dated_tree = NULL, missing_taxa = NULL, dating_method = "mrbayes", adding_criterion = "random", mrbayes_output_file = "mrbayes_tree_add_dates.nexus") { dated_tree <- tree_check(tree =...
"dataAGGR"
library(amt) data(amt_fisher) set.seed(123) tr <- make_trast(amt_fisher[1:50, ], res = 5) mini_fisher <- amt_fisher[1:40, ] mcp <- hr_mcp(mini_fisher) loc <- hr_locoh(mini_fisher) kde <- hr_kde(mini_fisher) mini_fisher1 <- amt_fisher[11:50, ] mcp1 <- hr_mcp(mini_fisher1) loc1 <- hr_locoh(mini_fisher1) kde1 <- hr_kde(mi...
brute_IDs <- function(total.length, redundancy, alphabet, num.tries = 10, available.colors = NULL) { if (missing(alphabet)) { stop("Error: you need to enter an 'alphabet size,' e.g. the number of paint colors you have") } if (missing(total.length)) { stop("Error: you need to enter the total length of the ...
context("ashr with half-uniform mixture priors") test_that("mixcompdist=+uniform gives all non-negative values for b and zero for a", { set.seed(1); z=rnorm(10); z.ash=ash(z,1,mixcompdist="+uniform") k = length(z.ash$fitted_g$pi) expect_true(all(z.ash$fitted_g$b >= rep(0,k))) expect_equal(z.ash$fitted_g$a,rep(0...
women names(women) height attach(women) height weight women$height g <- "My First List" h <- c(25, 26, 18, 39) j <- matrix(1:10, nrow=5) k <- c("one", "two", "three") mylist <- list(title=g, ages=h, j, k, women) mylist mylist[[2]] mylist[[5]] plot(x=height, y=weight, type='b', lty=5, pch=11, fg='red', bg='green',...
stratsamp <- function(n, distribution, parameters, p) { lims <- find_strata(p, distribution, parameters) outmat <- matrix(data = NA, nrow = n, ncol = length(p)-1) counts <- rep(0, length(lims)-1) while (any(counts < n)) { r <- distribution_sampling(1, distribution, parameters) intvl <- fi...
context("mlc") suppressPackageStartupMessages(library(caret)) set.seed(1) mat <- matrix(rnorm(300), ncol = 3, nrow = 100) colnames(mat) <- letters[1:3] y <- sample(factor(c("a", "b")), 100, replace = TRUE) test_that("fit mlc",{ expect_is( mr <- mlc(mat,y), "list") expect_equal(names(mr), c("a", "b",...
semprobit <- function(formula, W, data, subset, ...) { cl <- match.call() mf <- match.call(expand.dots = FALSE) m <- match(c("formula", "data", "subset"), names(mf), 0L) mf <- mf[c(1L, m)] mf$drop.unused.levels <- TRUE mf[[1L]] <- as.name("model.frame") mf <- eval(mf, paren...
tar_resources_url <- function( handle = NULL ) { out <- resources_url_init( handle = handle ) resources_validate(out) out }
export_amira.path<-function(vertices,filename,Lines=c(1:(dim(vertices)[1]-1)-1,-1),path) { while(tolower(paste(filename,".am",sep=""))%in%list.files(path)!=FALSE){ i<-1 filename<-paste(filename,"(",i,")",sep="") i<-i+1 } cat(paste(" file = paste(path, "/", filename, ".am", sep = ""), append =...
test_that("translations", { expect_identical(pow(5, 2), 25) expect_identical(phi(0), 0.5) expect_equal(phi(2), 0.9772499, tolerance = 0.0000001) x <- NA log(x) <- log(5) expect_equal(x, 5) expect_equal(logit(0.5), 0) expect_equal(logit(1), Inf) x <- NA logit(x) <- logit(0.75) expect_equal(x, 0.75)...
read.cross.csv <- function(dir, file, na.strings=c("-","NA"), genotypes=c("A","H","B","D","C"), estimate.map=TRUE, rotate=FALSE, ...) { if(missing(file)) file <- "data.csv" if(!missing(dir) && dir != "") { file <- file.path(dir, file) } args <- list(...) if...
gbm.perf <- function(object, plot.it=TRUE, oobag.curve=FALSE, overlay=TRUE, method, main="") { if(!is.logical(plot.it) || (length(plot.it)) > 1 || is.na(plot.it)) stop("plot.it must be a logical - exclud...
test_that("gives warning markers are not correct", { expect_warning(style_text(c( "1+1", " " ))) }) test_that("trailing spaces are stripped when checking marker and written back", { expect_equal( style_text(c( " "1+1", " )) %>% as.character(), c(" ) }) test_that("...
genscorestat<-function(scores,group,correct=0){ N<-length(group); MV<-table(group) refg<-names(MV)[1] if(is.numeric(group)) refg<-as.numeric(refg) if(length(MV)!=2){ message("genscorestat works only for two groups") out<-NA }else{ abar<-mean(scores) ahat<-mean(scores^2) vv<-...
"dccm.nma" <- function(x, nmodes=NULL, ncore=NULL, progress = NULL, ...) { nma <- x if (missing(nma)) stop("dccm.nma: must supply a 'nma' object, i.e. from 'nma'") if(!"nma" %in% class(nma)) stop("dccm.nma: must supply 'nma' object, i.e. from 'nma'") ncore <- setup.ncore(ncore, bigmem...
stat.entropyFunction = function(bitString) { pT = sum(bitString)/length(bitString) pF = 1-pT if (pT==1 || pT==0) { e = 0 } else { e = -pT*log2(pT)-pF*log2(pF) } return(e) }
"ChickWeight" <- structure(list( weight = c(42, 51, 59, 64, 76, 93, 106, 125, 149, 171, 199, 205, 40, 49, 58, 72, 84, 103, 122, 138, 162, 187, 209, 215, 43, 39, 55, 67, 84, 99, 115, 138, 163, 187, 198, 202, 42, 49, 56, 67, 74, 87, 102, 108, 136, 154, 160, 157, 41, 42, 48, 60, 79, 106, 141, 164,...
NULL dcmp = function(x, lambda, nu, log = FALSE) { prep = prep.zicmp(length(x), lambda, nu) dcmp_cpp(x, prep$lambda, prep$nu, take_log = log) } rcmp = function(n, lambda, nu) { prep = prep.zicmp(n, lambda, nu) ymax = getOption("COMPoissonReg.ymax") rcmp_cpp(n, prep$lambda, prep$nu, ymax = ymax) } pcmp = function(x...
groupAndRename <- function(obj, var, before, after, addNA=FALSE) { groupAndRenameX(obj=obj, var=var, before=before, after=after, addNA=addNA) } setGeneric("groupAndRenameX", function(obj, var, before, after, addNA=FALSE) { standardGeneric("groupAndRenameX") }) setMethod(f="groupAndRenameX", signature=c("factor"), d...
ans <- pl(amount = c(1, -1), timestamp = c(2, 3), price = c(1, 2), along.timestamp = 3:1, vprice = 1:3) expect_equal(ans[[1]]$timestamp , 1:3) expect_equal(unname(ans[[1]]$pl), c(0,1,1))
REND <- function(TPDc = NULL, TPDs = NULL){ if (is.null(TPDc) & is.null(TPDs)) { stop("At least one of 'TPDc' or 'TPDs' must be supplied") } if (!is.null(TPDc) & class(TPDc) != "TPDcomm"){ stop("The class of one object do not match the expectations, Please, specify if your object is a TPDc or a TP...
r1sd <- function(x, na = TRUE) { return((x - mean(x, na.rm = na)) / (1 * sd(x, na.rm = na))) }
QRSimul <- function(VecX, tau, times, subj, X, y, d, kn, degree, lambda, gam){ dim = length(subj) X = matrix(X, nrow=dim) H = length(tau) px = ncol(X) n = length(unique(subj)) if(px != length(VecX)) stop("the length of VecX and the number of covariate(s) must match") XX = as.matrix(X) if(all(X[,1]==1)) VecX[1]=1 else V...
writeEnvelope <- function(obj, centerfun = mean) { if(inherits(obj, c("SpatialPoints", "SpatialPointsDataFrame"), which = FALSE)) { SpatialPointsEnvelope(obj) } else if(inherits(obj, "list") && length(obj) > 0 && all(vapply( X = obj, FUN = inherits, FUN.VALU...
session <- function(url, ...) { session <- structure( list( handle = httr::handle(url), config = c(..., httr::config(autoreferer = 1L)), response = NULL, url = NULL, back = character(), forward = character(), cache = new_environment() ), class =...
context('Test the creation of custom indicators') data(forestgap) data(serengeti) datasets <- list(forestgap[3:4], forestgap[1:2]) test_methods <- function(teststring, datalength, obj) { ok_print <- any(grepl(teststring, capture.output(print(obj)))) expect_true(ok_print) ok_summary <- any...
testthat::context("H2O AUTOML TEST") test_that("Fire up H2O", { testthat::skip_on_cran() h2o.init( nthreads = -1, ip = 'localhost', port = 54321 ) model_spec <<- automl_reg(mode = 'regression') %>% set_engine( engine = 'h2o', max_runtime_sec...
library(pcalg) amat1 <- t(cbind(c(0,1,0,1,0),c(0,0,1,0,1),c(0,0,0,1,1),c(0,0,0,0,1),c(0,0,0,0,0))) amat2 <- t(cbind(c(0,1,0,1,1),c(0,0,0,0,1),c(0,0,0,0,1),c(0,0,0,0,1),c(0,0,0,0,0))) g1 <- as(amat1,"graphNEL") g2 <- as(amat2,"graphNEL") res <- compareGraphs(g1,g2) if ((round(res["tpr"],5)!=0.83333) | (round(res["fpr"],...
skip_tests_for_cran <- TRUE skip_maxnet <- FALSE skip_maxent.jar <- TRUE skip_bioclim <- TRUE skip_simDiff <- TRUE library(dplyr) options(warn=-1) set.seed(48) occs <- read.csv(file.path(system.file(package="dismo"), "/ex/bradypus.csv"))[,2:3] envs.orig <- raster::stack(list.files(path=paste(system.file(package='dismo'...
MCpriorIntFun <- function(Nsim=200, prior, Hpar, dimData, FUN=function(par,...){as.vector(par)}, store=TRUE, show.progress = floor(seq(1, Nsim, length.out = 20 ) ), Nsim.min=Nsim, precision = 0, ...) { start.time=proc.time() no...
NULL "ghp100k"
kkmeans <- function(K, parameters) { state <- list() state$time <- system.time({ H <- eigen(K, symmetric = TRUE)$vectors[, 1:parameters$cluster_count] objective <- sum(diag(t(H) %*% K %*% H)) - sum(diag(K)) H_normalized <- H/matrix(sqrt(rowSums(H^2, 2)), ...
translogEla <- function( xNames, data, coef, coefCov = NULL, dataLogged = FALSE ) { checkNames( c( xNames ), names( data ) ) nExog <- length( xNames ) nCoef <- 1 + nExog + nExog * ( nExog + 1 ) / 2 if( nCoef > length( coef ) ) { stop( "a translog function with ", nExog, " exogenous variables", ...
.init_base_test_templ <- function() { templ_dir <- file.path(get_templ_dir(), "BaseTestProjectTemplate") if (dir.exists(templ_dir)) { return(templ_dir) } unzip(file.path("data", "BaseTestProjectTemplate.zip"), exdir = get_templ_dir()) build_prj <- RSuite::prj_start("BaseTestProjectBuild", skip_rc = TRUE, ...
getGVGenotype <- function(ped) { if (hasGenotype(ped)) { genotype <- ped[ , c("id", "first", "second")] } else { genotype <- NULL } genotype }
NULL kernel <- setClass('kernel', representation(type='character', kernel='matrix', pathway='pathway')) setValidity('kernel', function(object){ msg <- NULL valid <- TRUE if( !isSymmetric(round(object@kernel),10) ){ ...
LModularity <- function(cor.matrix, method = optimal.community, ...){ if(any(cor.matrix < 0)){ warning("Some correlations are negative. Using squared correlations.") cor.matrix = cor.matrix^2 } g = graph.adjacency(cor.matrix, weighted = TRUE, mode = 'undirected') comm = method(g, ...) modules = uniq...
LBRecap.custom.part=function( data, last.column.count=FALSE, partition, neval=1000, by.incr=1, output=c("base","complete")){ output=match.arg(output) if(!(any(c("data.frame","matrix","array","table") %in% class(data)))){ stop("input data must be a data.frame or a matrix object or an array") } data.matrix=...
plot.ref.grid = function(x, ...) { plot(x = as(x, "emmGrid"), ...) } ref.grid = function(...) { .Deprecated(new = "ref_grid", old = "ref.grid", package = "emmeans") ref_grid(...) } recover.data = function(object, ...) UseMethod("recover.data") recover.data.call = function(...) recover_data.call(......
distNumeric <- function(x, y, method = "mrw", xyequal = TRUE) { if((is.matrix(x)&&is.matrix(x))==FALSE) stop("x and y must be a matrix object!") if(ncol(x)!=ncol(y)) stop(sQuote("x")," and ",sQuote("y"), " must have the same number of columns") if (xyequal == TRUE) { span <- apply(x, 2, funct...
hullArea <- function (x,y) { ne <- length(x) harea <- abs (0.5 * ( (x[1:(ne-1)] %*% y[2:ne]) - ( y[1:(ne-1)] %*% x[2:ne]) ) ) harea }
loadNamespace("fields") loadNamespace("graphics") loadNamespace("ggplot2") loadNamespace("hash") map.build <- function(data, labels=NULL, xdim=10, ydim=5, alpha=.3, train=1000, normalize=F...
roc_aunu <- function(data, ...) { UseMethod("roc_aunu") } roc_aunu <- new_prob_metric( roc_aunu, direction = "maximize" ) roc_aunu.data.frame <- function(data, truth, ..., options = list(), ...
getAlbumInfo<-function(album_id,token){ req<-httr::GET(paste0("https://api.spotify.com/v1/albums/",album_id),httr::config(token = token)) json1<-httr::content(req) json2<-jsonlite::fromJSON(jsonlite::toJSON(json1)) df <- data.frame("id" = json2$id, "artist" = as.character(json2$artists$name),"name" = json2$name...
lsv <- function(data,k1,p = 6,q = 0,interval = c(0.001,0.999)) { n <- length(data) k <- 1:k1 sdrunning <- function(kscale) { sd(running(data,fun = sum,width = kscale,by = kscale)) } s <- sapply(k,sdrunning) d1 <- sum((s^4)/(k^p)) g2 <- function(H) { ckH <-...
add.column <- function(lprec, x, indices) { if(missing(indices)) { if(length(x) != dim(lprec)[1]) stop("the length of ", sQuote("x"), " is not equal to the number of ", "constraints in the model") epsel <- .Call(RlpSolve_get_epsel, lprec) indices <- which(abs(x) > epsel) x <- x[indic...
higherMomentsIV <- function(formula, data, verbose=TRUE){ cl <- match.call() check_err_msg(checkinput_highermomentsiv_formula(formula=formula)) check_err_msg(checkinput_highermomentsiv_data(data=data)) check_err_msg(checkinput_highermomentsiv_formulaVSdata(formula=formula, data=data)) check_err_msg(checkin...
NULL fclust_read <- function(filename = "") { if (nchar(filename) == 0) stop("'filename' cannot be an empty string") tmp <- c("nbElt", "nbAss", "nbXpr", "opt.method", "opt.mean", "opt.model", "opt.jack", "jack", "opt.na", "opt.repeat", "affectElt", "fobs", "mOccur", "xpr"...
gh_whoami <- function(.token = NULL, .api_url = NULL, .send_headers = NULL) { .token <- .token %||% gh_token(.api_url) if (isTRUE(.token == "")) { message("No personal access token (PAT) available.\n", "Obtain a PAT from here:\n", "https://github.com/settings/tokens\n", "For ...
.viridisOpts <- function (n, alpha = 1, begin = 0, end = 1, option = "D",...) { if (begin < 0 | end < 0 | begin > 1 | end > 1) { stop("begin and end must be in [0,1]") } option <- switch(option, A = "A", magma = "A", B = "B", inferno = "B", C = "C", plasma = "C", D = "D", viridis = "D", {...
get_committee_by_name <- function(NAME, cycle=2018, page = 1, myAPI_Key){ API = 'campaign-finance' if(!validate_cycle(cycle)) stop("Incorrect cycle") if(is.character(NAME)){ NAME <- gsub(' ', '%20', NAME) query <- sprintf("%s/committees/search.json?query=%s", cycle, NAME) pp_query(query, API, page...
activity_id <- function(x) { UseMethod("activity_id") } activity_id.eventlog <- function(x){ return(attr(x, "activity_id")) } activity_id.eventlog_mapping <- function(x) { return(x$activity_identifier) } activity_id.activitylog <- function(x){ return(attr(x, "activity_id")) } activity_id.activitylog_mapping <- func...
SHASH <- function (mu.link="identity", sigma.link="log", nu.link ="log", tau.link="log") { mstats <- checklink( "mu.link", "Sinh-Arcsinh", substitute(mu.link), c("inverse", "log", "identity", "own")) dstats <- checklink("sigma.link", "Sinh-Arcsinh", substitute(sigma.link), ...
proximity_builder <- function(im.res, neighborhood = "ar1", type = c("sparse", "full"), weight = "binary", phi = 1, r = NULL, h = NULL, w = NULL, include.coords = FALSE, ...
.getPQ <- function(X, V, Lambda, Sigma, Psi) { p <- NA q <- NA if(!.minu(X)) { if(is.vector(X)) { p <- 1 q <- 1 } else { p <- dim(X)[1] q <- dim(X)[2] } } if(!.minu(V)) { if(is.na(q)) { q <- ifelse(is.vector(V), 1, dim(V)[1]) } } if(!.minu(Lambda)) { i...
round_df_char <- function(df, digits, pad = " ", na_vals = NA) { nas <- is.na(df) if (!is.data.frame(df)) { df <- as.data.frame.matrix(df, stringsAsFactors = FALSE) } rn <- rownames(df) cn <- colnames(df) df <- as.data.frame(lapply(df, function(col) { if (suppressWarnings(all(!is....
Qstat.reg.sb = function(DATA1, DATA2, vecA, Psize, gamma, Bsize, sigLev) { Tsize = nrow(DATA1) Nsize = Tsize - Psize vecQ.BP = matrix(0,Psize,1) vecQ.LB = matrix(0,Psize,1) vecCRQ = crossqreg.max(DATA1, DATA2, vecA, Psize) for (k in 1:Psize){ ...
plots <- function(..., n_rows = NULL, n_columns = NULL, guides = NULL, tags = FALSE, tag_prefix = NULL, tag_suffix = NULL, tag_sep = NULL, title = NULL, subti...
"model.comp.bayes.parobs" <- function(object, type="lpml", verbose=FALSE, ncores=NULL) { nkeep <- object$mcmc$nkeep Sigmahat <- apply(object$mcmc.draws$Sigma, c(1,2), mean) Omegahat <- apply(object$mcmc.draws$Omega, c(1,2), mean) thetahat <- rowMeans(object$mcmc.draws$theta) if (!is.null(ncores)) { ncores_ <- ...
copy_filt <- function(abund,threshold){ if(is.null(dim(abund)) == FALSE){ sapply(1:ncol(abund), function(colnum){temp = abund[,colnum] if(threshold == round(threshold)){ rownums = which(temp < threshold) }else{ rownums = which(temp < sum(temp)*threshold) } abund[rownums, colnum] <...
shiftid <- function (e_ij1, e_ij2, e_i1, e_i2, time1, time2, industry.names = NULL, shift.method = "Dunn", gerfin.shifts = "mean", print.results = TRUE, plot.results = FALSE, plot.colours = NULL, plot.title = NULL...
do.findmain <- function ( ramclustObj = NULL, cmpd = NULL, mode = "positive", mzabs.error = 0.005, ppm.error = 10, ads = NULL, nls = NULL, scoring = "auto", plot.findmain = TRUE, writeMat = TRUE, writeMS = TRUE, use.z = TRUE) { if(is.null(ramclustObj)) { stop("must supply ramc...
PrintToPDF <- function(Path, OutputName, ObjectList = NULL, Tables = FALSE, MaxPages = 500, Title = "Model Output", Width = 12, Height = 7, ...
library(testthat) test_that("it returns correct data", { r <- ptd_spc_options( value_field = "value_field", date_field = "date_field", facet_field = "facet_field", rebase = as.Date("2020-01-01"), fix_after_n_points = NULL, improvement_direction = "increase", target = 1, trajectory = "t...
ergm.estimate<-function(init, model, statsmatrices, statsmatrices.obs=NULL, epsilon=1e-10, nr.maxit=1000, nr.reltol=sqrt(.Machine$double.eps), metric="lognormal", method="Nelder-Mead", calc.mcmc.se=TRUE, hessianflag=TRUE, ...
1:4 %*% 1:4 sum(1:4 * 1:4)
wod_4hist_k_p <- function( obs_index, surv.object, covariate.data , nruns , m ) { actual_data <- cbind( covariate.data , surv.object[,1], surv.object[,2] ) time_index <- ncol(actual_data) - 1 status_index <- ncol(actual_data) data_length <- nrow(actual_data) obs_influences <- rep(...
summarizeadd2 <- function(abo,probe.effects){ inds.all = indexProbes(abo,which="pm") if(dim(Biobase::exprs(abo))[2] != 1) stop("\n error: to many chips \n\n") if(sum( names(inds.all) == names(probe.effects)) != length(probe.effects)) { reorderind <- as.numeric(factor(names(probe.e...
library(buildmer) library(testthat) test_that('build.formula',{ form1 <- Reaction ~ Days + (Days|Subject) terms <- tabulate.formula(form1) form2 <- build.formula(dep='Reaction',terms) library(lme4) check <- function (f) resid(lmer(f,sleepstudy)) expect_equal(check(form1),check(form2)) })
make_true_parameter_MRMC <- function(StanS4class) { f <- StanS4class z <- extract_EAP_CI(f,"z",f@dataList$C )$z.EAP dz <- extract_EAP_CI(f,"dz",f@dataList$C-1 )$dz.EAP mu <- extract_EAP_by_array(f,mu) v <- extract_EAP_by_array(f,v) }
predictLKrigFixedFunction <- function(object, xnew=NULL, Znew = NULL, drop.Z = FALSE, collapseFixedEffect = FALSE){ if( is.null(xnew)){ xnew<- object$x } nt<- object$nt nZ<- object$nZ ind.drift<- c( rep( TRUE, (nt-nZ) ), rep(...
setMethodS3("segmentByHaarSeg", "RawGenomicSignals", function(this, ..., cache=FALSE, force=FALSE, verbose=FALSE) { verbose <- Arguments$getVerbose(verbose) if (verbose) { pushState(verbose) on.exit(popState(verbose)) } verbose && enter(verbose, "Segmenting") verbose && cat(verbose, "Chrom...
options(shiny.trace = F) require(shiny) require(shinysky) shinyServer(function(input, output, session) { observe({ if (input$id_blank == 0) return() showshinyalert(session, "shinyalert1", paste("You have clicked", "blank")) }) observe({ if (input$id_primary...
hidden_paths <- function(model){ if(!inherits(model, c("hmm", "mhmm"))) stop("Argument model must be an object of class 'hmm' or 'mhmm.") if(inherits(model,"mhmm")){ model <- combine_models(model) mix <- TRUE } else mix <- FALSE if(model$n_channels == 1){ model$observations <-...
fitSpliced=function(cell, body, tail, method,thresh=NULL){ if(method == "BestFit"){ return(fitSplicedBestFit(cell, body, tail, thresh0 = 0.7, thresh.max = 0.98)) } else { if(method != "Fixed"){ thresh<-fitThreshold(cell, body, tail, method) } pars=fitSplicedPar(cell, thresh, body, tail) ...