Dataset Viewer
Auto-converted to Parquet Duplicate
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 }
End of preview. Expand in Data Studio

No dataset card yet

Downloads last month
15