str.replace.by.blocks | R Documentation |
Replaces in str every occurence of pattern by replacement
## S3 method for class 'replace.by.blocks' str(str, pattern, replacement, blocks = NULL, sub.txt = "SUB", block.start, block.end, block.ignore = NULL, use.levels = NULL, fixed = TRUE, only.replace.smaller.than = NULL, only.replace.larger.than = NULL)
str |
the string to replaced |
pattern |
the substring to be replaced |
replacment |
the new substrings |
block |
a block retrieved from str.block.pos alternatively, you can provide block.start and block.end |
block.start |
string with which the blocks start, e.g. "(" |
block.end |
string with which the blocks end, e.g. ")" |
only.replace.smaller.than |
if not NULL only replaces matches whose number of characters is less or equal to only.replace.smaller.than |
only.replace.larger.than |
if not NULL only replaces matches whose number of characters is bigger or equal to only.replace.larger.than |
a string
## Not run: # Replace latex fractions str = "5+\frac{x^2+x^2}{1+\frac{2}{x*5}}*2" str.replace.by.blocks(str,"\frac{_SUB_}{_SUB_}","(_SUB1_)/(_SUB2_)", block.start = "{", block.end = "}") str.replace.by.blocks(str,"\frac{_SUB_}{_SUB_}","(_SUB1_)/(_SUB2_)", block.start = "{", block.end = "}", only.replace.larger.than=20) str.replace.by.blocks(str,"\frac{_SUB_}{_SUB_}","(_SUB1_)/(_SUB2_)", block.start = "{", block.end = "}", only.replace.smaller.than=20) str ="-\frac{\sigma_{m}-\beta\sigma_{b}}{\beta-1}=\frac{\sigma_{m}-\beta\sigma_{b}}{1-\beta}" str ="\frac{1}{2}=\frac{3}{4}" str.replace.by.blocks(str,"\frac{_SUB_}{_SUB_}","(_SUB1_)/(_SUB2_)", block.start = "{", block.end = "}") ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.