R/string_extract_part.R

Defines functions string_extract_part

Documented in string_extract_part

## File Name: string_extract_part.R
## File Version: 0.11

string_extract_part <- function( vec, part=1, sep="__", remove_empty=TRUE)
{
    v1 <- strsplit(paste(vec), split=sep)
    m1 <- lapply( v1, FUN=function(ll){
                if (remove_empty){
                    ll <- ll[ ll !=""]
                }
                ll[ part]
                } )
    m1 <- unlist(m1)
    return(m1)
}

Try the miceadds package in your browser

Any scripts or data that you put into this service are public.

miceadds documentation built on May 29, 2024, 11:05 a.m.