https://github.com/cran/kdevine
Raw File
Tip revision: a7251e97a44d47907c9796e2d10898da755d415a authored by Thomas Nagler on 18 October 2022, 11:25:15 UTC
version 0.4.4
Tip revision: a7251e9
extract_names.R
extract_nums <- function(lst){
    unlist(sapply(lst, 
                  function(x)
                      ifelse(length(x) > 2,
                             x[[3]]$name,
                             x[[2]])))
}

extract_all_nums<- function(lst){
    len <- max(which(substr(names(lst), 1, 1) == "T"))
    sapply(lst[1:len], function(x) extract_nums(x))
}

### naming in RVine routine
naming <-  function(numb){ 
    bef <- paste(as.character(numb[2]),
                 as.character(numb[1]),
                 sep=",",
                 collapse="")
    aft <- if(length(numb) > 2){
        gsub(" ",
             ",",
             do.call(paste, as.list(as.character(numb[3:length(numb)])))) 
    }  else ""
    sep <- if(length(numb) > 2) " ; " else ""
    paste(bef, aft, sep=sep, collapse="")
}

split_num <- function(x){
    unlist(lapply(strsplit(x, " ; "), strsplit, split = ","))
}
split_name <- function(x){
    unlist(lapply(strsplit(x, " ; ", fixed = TRUE), strsplit, split = ","))
}
back to top