enum: Get enumeration value(s) based on the enum name(s)

Description Usage Arguments Value See Also Examples

Description

There is a builtin ENUM data set storing enumerations that are quite handy when applying mso-family functions.

Usage

1
enum(enum_name, ..., family = NULL, unlist = TRUE, bare = FALSE)

Arguments

enum_name

vector, can be

scalar character

e.g., "msoChart". In this case, you can pass other characters in ...

vector character

e.g, c("msoChart", "msoTable") or list("msoChart", "msoTable"). In this case, ... is omitted.

scalar symbol

e.g., msoChart. In this case, you can pass other symbols in ...

vector symbol

e.g, c(msoChart, msoTable) or list(msoChart, msoTable). In this case, ... is omitted.

...

When enum_name is scalar, you can pass the rest of the enum_names here.

family

character vector of the enumeration families, e.g., "MsoFileType". You can use names(ENUM) to check the full list. When it is defined, the function will only search enumerations within the families specified. Default NULL, i.e. the function will search the whole ENUM data set. You can only input the initial letters of the families.

unlist

logical, whether unlist the result. Default TRUE.

bare

logical, whether only return bare enumeration numbers. Default FALSE.

Value

If unlist = TRUE

return a vector, with a vector of 'family' attribute on the vector (of same length as the result)

If unlist = FALSE

return a list, with a 'family' attribute on each element

If enum_name is NULL or NA

return all the enumerations that match

If nothing is found

return NA

See Also

data:ENUM

Examples

 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
## Not run: 
enum(msoChart)  # equivalent to enum("msoChart")
# msoChart 
#        3 
# attr(,"family")
# [1] "msoShapeType"

enum(msoChart, unlist=FALSE)  # or enum("msoChart", unlist=FALSE)
# $`msoChart`
# [1] 3
# attr(,"family")
# [1] "msoShapeType"

enum(msoChart, msoTable)  # or enum(c(msoChart, msoTable))
                          # or enum(msoChart, family="Mso")
# msoChart   msoTable 
#        3         19 
# attr(,"family")
# [1] "msoShapeType" "msoShapeType"

enum(msoChart, family=c("Xl", "Wd"))  # "msoChart" not in these families
# [1] NA

enum(NULL, family="XlAxisGroup")  # return all the enums of "XlAxisGroup"
#   xlPrimary xlSecondary 
#           1           2 
# attr(,"family")
# [1] "XlAxisGroup" "XlAxisGroup"

enum(msoChart, bare=TRUE)  # only return bare number
# [1] 3

# feel free to use purrr::as_mapper
getEnum <- function(family, enum_name) {
    purrr:::as_mapper(c(family, enum_name))
}
getEnum("MsoShapeType", "msoChart")
# [1] 3

## End(Not run)

madlogos/aseshms documentation built on May 21, 2019, 11:03 a.m.