Description Usage Arguments Details Value Author(s) Examples
Generates an
1 |
x |
a factor or character vector that can be transformed to a factor |
desc |
a data.frame containing at least one column with all level of the factor in 'x'. |
ref |
a character vector indicating which column of the data.frame in 'desc' contains the levels of the factor 'x' |
FIXME: more details should follow
An object of class fctr (that contains the class factor) and can be used as a standard factor.
Thomas Fabbro <thomas.fabbro@unibas.ch>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | f <- c("a", "b", "c", "a", "a")
l <- data.frame(orig = c("a", "b", "c", "d"),
lang1 = c("A", "B", "C", "D"),
lang2 = c("first", "second", "third", "last"),
order1 = c(5, 3, 4, 2),
order2 = c("z", "y", "x", "w"),
group1 =c("A", "B", "B", "B")
)
sf <- fctr(f, l)
use(sf, "lang1")
use(sf, "lang2")
use(sf, "lang2", reorder = "order1")
use(sf, "lang1", drop = FALSE)
## or
f <- c("a", "b", "c", "a", "a")
l <- data.frame(lang1 = c("A", "B", "C", "D"),
lang2 = c("first", "second", "third", "last"),
lang3 = c("a", "b", "c", "d"),
order1 = c(5, 3, 4, 2),
order2 = c("z", "y", "x", "w"),
group1 =c("A", "B", "B", "B")
)
sf <- fctr(f, l, ref = "lang3")
## or
catinfo <- c("nz", "nz", "ch", "fr", "ch")
labeltable <- data.frame(lower = c("nz", "ch", "fr", "it"),
alpha2code = c("NZ", "CH", "FR", "IT"),
alpha3code = c("NZL", "CHE", "FRA", "ITA"),
english = c("New Zealand", "Switzerland", "France", "Italy"),
german = c("Neuseeland", "Schweiz", "Frankreich", "Italien"),
iso3166 = c(554, 756, 250, 380))
## you can easily thake the whole list from e.g. wikipedia
f <- fctr(catinfo, labeltable)
use(f, "alpha2code")
use(f, "english")
use(f, "german")
use(f, "alpha3code", reorder = "iso3166")
use(f, "alpha3code", drop = FALSE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.