I hereby claim:
- I am mrdwab on github.
- I am anandakpec (https://keybase.io/anandakpec) on keybase.
- I have a public key whose fingerprint is DA48 E710 3EDA 383B F911 85F4 95AD 8366 3CB7 5B67
To claim this, I am signing this object:
| trim_list <- function(x, relist = TRUE, convert = FALSE) { | |
| x <- replace(x, lengths(x) == 0, NA_character_) | |
| y <- unlist(x, use.names = FALSE) | |
| y[!nzchar(y)] <- NA_character_ | |
| out <- trim_vec(y, TRUE) | |
| if ((attr(out, "test") == "clean") & (!isTRUE(convert))) x | |
| if (isTRUE(convert)) out <- type.convert(out, as.is = TRUE) | |
| if (isTRUE(relist)) { | |
| out <- split(out, factor(rep.int(seq.int(length(x)), lengths(x)))) | |
| if (is.null(names(x))) unname(out) else `names<-`(out, names(x)) |
| dt1 <- fread("V1 V2 V3 | |
| x b;c;d 1 | |
| y d;ef 2 | |
| z d;ef 3 | |
| m tmp 4 | |
| n tmp 5 | |
| n x;yz 5") | |
| dt1[4, V2:=''] # this record will be lost because V2 value is empty string | |
| dt1[5, V2:=NA_character_] # NA value is processed correctly |
| library(tidyverse) | |
| library(data.table) | |
| library(microbenchmark) | |
| set.seed(1) | |
| s <- sample(5, 10000, TRUE) | |
| Sample <- rep(seq_along(s), s) | |
| df <- data.frame(Sample, | |
| motif = sample(LETTERS[1:10], length(Sample), TRUE), | |
| chromosome = sample(2, length(Sample), TRUE)) |
| <html> | |
| <head> | |
| <script src="https://code.jquery.com/jquery-2.1.3.min.js"></script> | |
| <style> | |
| video { | |
| width: 100%; | |
| height: auto; | |
| } | |
| </style> | |
| </head> |
| # https://stackoverflow.com/questions/43350554/r-filling-in-empty-variables | |
| fun1 <- function() { | |
| apply(t(df), 2, function(x) { | |
| conds <- rowSums(cbind(x, dplyr::lag(x), dplyr::lead(x)), na.rm = T)==2 | |
| x[conds] <- 1 | |
| x | |
| }) %>% t() | |
| } |
I hereby claim:
To claim this, I am signing this object:
| # server.R | |
| library(shiny) | |
| shinyServer(function(input, output) { | |
| ## Start by creating a reactive version of the dataset listing. This | |
| ## will then let us access the data for use in dynamically creating | |
| ## the listing of the available datasets. We only need the "id" | |
| ## and "title" datasets. |
| kobo_time_parser_UTC <- function(instring) { | |
| tmp <- gsub("\\.\\d{3}|:", "", instring) | |
| tmp <- chartr(" ", "0", format(tmp, justify = "left", width = 22)) | |
| as.POSIXct(strptime(tmp, format = "%Y-%m-%dT%H%M%S%z", tz = "UTC")) | |
| } | |
| kobo_time_parser <- function(indatetime, timezone = Sys.timezone()) { | |
| format(kobo_time_parser_UTC(indatetime), tz = timezone, usetz = TRUE) | |
| } |
| ## Helper functions. Won't bother exporting. | |
| dt_check <- function(indt) { | |
| if (!is.data.table(indt)) as.data.table(indt) else indt | |
| } | |
| g_s <- function(indt, group) indt[, .N, by = group] | |
| g_n <- function(indt, group, size) indt[, list(ss = size), by = group] | |
| g_f <- function(indt, group, size) indt[, list(ss = ceiling(.N * size)), by = group] | |
| g_l <- function(indt, group, size) setnames(data.table(names(size), unname(size)), c(group, "ss"))[] | |
| g_sel <- function(indt, select) { | |
| if (is.null(names(select))) { |
| meltList <- function(inlist) { | |
| require(data.table) | |
| f <- function(l) { | |
| names(l) <- seq_along(l) | |
| lapply(l, function(x) { | |
| x <- setNames(x, seq_along(x)) | |
| if(is.list(x)) f(x) else x | |
| }) | |
| } | |
| temp <- unlist(f(inlist)) |