Load R package from character string
Use the character.only argument foo <- “ggplot2” library(foo,character.only=TRUE)
Use the character.only argument foo <- “ggplot2” library(foo,character.only=TRUE)
Try echo “abcdefg” | fold -w1 Edit: Added a more elegant solution suggested in comments. echo “abcdefg” | grep -o .
You can use deparse and substitute to get the name of a function argument: myfunc <- function(v1) { deparse(substitute(v1)) } myfunc(foo) [1] “foo”
You are not the only one who couldn’t find the solution. String doesn’t implement RandomAccessIndexType. Probably because they enable characters with different byte lengths. That’s why we have to use string.characters.count (count or countElements in Swift 1.x) to get the number of characters. That also applies to positions. The _position is probably an index into … Read more
echo “$string” | tr xyz _ would replace each occurrence of x, y, or z with _, giving A__BC___DEF__LMN in your example. echo “$string” | sed -r ‘s/[xyz]+/_/g’ would replace repeating occurrences of x, y, or z with a single _, giving A_BC_DEF_LMN in your example.
Character is an overloaded term that can mean many things. A code point is the atomic unit of information. Text is a sequence of code points. Each code point is a number which is given meaning by the Unicode standard. A code unit is the unit of storage of a part of an encoded code … Read more
The following works invoke it as select * from table(splitter(‘a,b,c,d’)) create or replace function splitter(p_str in varchar2) return sys.odcivarchar2list is v_tab sys.odcivarchar2list:=new sys.odcivarchar2list(); begin with cte as (select level ind from dual connect by level <=regexp_count(p_str,’,’) +1 ) select regexp_substr(p_str,'[^,]+’,1,ind) bulk collect into v_tab from cte; return v_tab; end; /
The reason this happens is because of the order in which the shell parses the command line: it parses (and removes) quotes and escapes, then replaces variable values. By the time $test gets replaced with One “This is two” Three, it’s too late for the quotes to have their intended effect. The simple (but dangerous) … Read more
Here is one way substring(“aabbccccdd”, seq(1, 9, 2), seq(2, 10, 2)) #[1] “aa” “bb” “cc” “cc” “dd” or more generally text <- “aabbccccdd” substring(text, seq(1, nchar(text)-1, 2), seq(2, nchar(text), 2)) #[1] “aa” “bb” “cc” “cc” “dd” Edit: This is much, much faster sst <- strsplit(text, “”)[[1]] out <- paste0(sst[c(TRUE, FALSE)], sst[c(FALSE, TRUE)]) It first splits … Read more
In XSLT 1.0 the upper-case() and lower-case() functions are not available. If you’re using a 1.0 stylesheet the common method of case conversion is translate(): <xsl:variable name=”lowercase” select=”‘abcdefghijklmnopqrstuvwxyz'” /> <xsl:variable name=”uppercase” select=”‘ABCDEFGHIJKLMNOPQRSTUVWXYZ'” /> <xsl:template match=”https://stackoverflow.com/”> <xsl:value-of select=”translate(doc, $lowercase, $uppercase)” /> </xsl:template>