Create icon-text elements

icontext(
  icon,
  text = list(NULL),
  ...,
  simplify = TRUE,
  provider = getOption("formattable.icon.provider", "glyphicon"),
  class_template = getOption("formattable.icon.class_template",
    "{provider} {provider}-{icon}")
)

Arguments

icon

a character vector or list of character vectors of icon names.

text

a character vector of contents.

...

additional parameters (reserved)

simplify

logical to indicating whether to return the only element if a single-valued list is resulted.

provider

the provider of icon set.

class_template

a character value to specifiy to template of the class with "{provider}" to represent provider value and "{icon}" to represent icon values.

Examples

icontext("plus")
#> <i class="glyphicon glyphicon-plus"></i>
icontext(c("star","star-empty"))
#> [[1]]
#> <i class="glyphicon glyphicon-star"></i>
#> 
#> [[2]]
#> <i class="glyphicon glyphicon-star-empty"></i>
#> 
icontext(ifelse(mtcars$mpg > mean(mtcars$mpg), "plus", "minus"), mtcars$mpg)
#> [[1]]
#> <i class="glyphicon glyphicon-plus"></i>
#> 21
#> 
#> [[2]]
#> <i class="glyphicon glyphicon-plus"></i>
#> 21
#> 
#> [[3]]
#> <i class="glyphicon glyphicon-plus"></i>
#> 22.8
#> 
#> [[4]]
#> <i class="glyphicon glyphicon-plus"></i>
#> 21.4
#> 
#> [[5]]
#> <i class="glyphicon glyphicon-minus"></i>
#> 18.7
#> 
#> [[6]]
#> <i class="glyphicon glyphicon-minus"></i>
#> 18.1
#> 
#> [[7]]
#> <i class="glyphicon glyphicon-minus"></i>
#> 14.3
#> 
#> [[8]]
#> <i class="glyphicon glyphicon-plus"></i>
#> 24.4
#> 
#> [[9]]
#> <i class="glyphicon glyphicon-plus"></i>
#> 22.8
#> 
#> [[10]]
#> <i class="glyphicon glyphicon-minus"></i>
#> 19.2
#> 
#> [[11]]
#> <i class="glyphicon glyphicon-minus"></i>
#> 17.8
#> 
#> [[12]]
#> <i class="glyphicon glyphicon-minus"></i>
#> 16.4
#> 
#> [[13]]
#> <i class="glyphicon glyphicon-minus"></i>
#> 17.3
#> 
#> [[14]]
#> <i class="glyphicon glyphicon-minus"></i>
#> 15.2
#> 
#> [[15]]
#> <i class="glyphicon glyphicon-minus"></i>
#> 10.4
#> 
#> [[16]]
#> <i class="glyphicon glyphicon-minus"></i>
#> 10.4
#> 
#> [[17]]
#> <i class="glyphicon glyphicon-minus"></i>
#> 14.7
#> 
#> [[18]]
#> <i class="glyphicon glyphicon-plus"></i>
#> 32.4
#> 
#> [[19]]
#> <i class="glyphicon glyphicon-plus"></i>
#> 30.4
#> 
#> [[20]]
#> <i class="glyphicon glyphicon-plus"></i>
#> 33.9
#> 
#> [[21]]
#> <i class="glyphicon glyphicon-plus"></i>
#> 21.5
#> 
#> [[22]]
#> <i class="glyphicon glyphicon-minus"></i>
#> 15.5
#> 
#> [[23]]
#> <i class="glyphicon glyphicon-minus"></i>
#> 15.2
#> 
#> [[24]]
#> <i class="glyphicon glyphicon-minus"></i>
#> 13.3
#> 
#> [[25]]
#> <i class="glyphicon glyphicon-minus"></i>
#> 19.2
#> 
#> [[26]]
#> <i class="glyphicon glyphicon-plus"></i>
#> 27.3
#> 
#> [[27]]
#> <i class="glyphicon glyphicon-plus"></i>
#> 26
#> 
#> [[28]]
#> <i class="glyphicon glyphicon-plus"></i>
#> 30.4
#> 
#> [[29]]
#> <i class="glyphicon glyphicon-minus"></i>
#> 15.8
#> 
#> [[30]]
#> <i class="glyphicon glyphicon-minus"></i>
#> 19.7
#> 
#> [[31]]
#> <i class="glyphicon glyphicon-minus"></i>
#> 15
#> 
#> [[32]]
#> <i class="glyphicon glyphicon-plus"></i>
#> 21.4
#> 
icontext(list(rep("star",3), rep("star",2)), c("item 1", "item 2"))
#> [[1]]
#> <i class="glyphicon glyphicon-star"></i>
#> <i class="glyphicon glyphicon-star"></i>
#> <i class="glyphicon glyphicon-star"></i>
#> item 1
#> 
#> [[2]]
#> <i class="glyphicon glyphicon-star"></i>
#> <i class="glyphicon glyphicon-star"></i>
#> item 2
#>