Description Usage Arguments Details Author(s) References See Also Examples
Convenience wrapper around 'structure()'.
1 | create_instance(of, with = NA, inherits = TRUE, attributes = NULL)
|
of |
|
with |
|
inherits |
|
attributes |
|
None yet.
Janko Thyson janko.thyson@gmail.com
http://github.com/rappster/instancer
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | # Intro -------------------------------------------------------------------
create_instance(of = "test_class")
create_instance(of = "test_class", with = letters[1:3])
create_instance(of = "test_class", with = letters[1:3], inherits = FALSE)
# Additional attributes ---------------------------------------------------
create_instance(of = "test_class", with = letters[1:3],
attributes = list(attr_1 = TRUE, attr_2 = "yep!"))
create_instance(of = "test_class", with = letters[1:3],
attributes = list(my_attrs = list(attr_1 = TRUE, attr_2 = "yep!")))
# Preserve data frames ----------------------------------------------------
# A data frame is automatically "reduced" to its list structure if no
# inheritance is involved
structure(mtcars, class = "test_class")
# Therefore it seems to be best to throw an error in case the user wants to try
# this in order to make it explicit to chose a list input if that's what he
# wants
create_instance(of = "test_class", with = mtcars, inherits = FALSE)
create_instance(of = "test_class", with = unclass(mtcars), inherits = FALSE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.