nc | R Documentation |
This is a wrapper to the function c
, however names the respective elements
according to their input object name. For this reason, nesting nc()
calls
is not recommended (joining independent nc()
calls via c()
is however reasonable).
nc(..., use.names = FALSE, error.on.duplicate = TRUE)
... |
objects to be concatenated |
use.names |
logical indicating if |
error.on.duplicate |
logical; if the same object name appears in the returning object
should an error be thrown? Default is |
Chalmers, R. P., & Adkins, M. C. (2020). Writing Effective and Reliable Monte Carlo Simulations
with the SimDesign Package. The Quantitative Methods for Psychology, 16
(4), 248-280.
\Sexpr[results=rd]{tools:::Rd_expr_doi("10.20982/tqmp.16.4.p248")}
Sigal, M. J., & Chalmers, R. P. (2016). Play it again: Teaching statistics with Monte
Carlo simulation. Journal of Statistics Education, 24
(3), 136-156.
\Sexpr[results=rd]{tools:::Rd_expr_doi("10.1080/10691898.2016.1246953")}
A <- 1
B <- 2
C <- 3
names(C) <- 'LetterC'
# compare the following
c(A, B, C) # unnamed
nc(A, B, C) # named
nc(this=A, B, C) # respects override named (same as c() )
nc(this=A, B, C, use.names = TRUE) # preserve original name
## Not run:
# throws errors if names not unique
nc(this=A, this=B, C)
nc(LetterC=A, B, C, use.names=TRUE)
## End(Not run)
# poor input choice names
nc(t.test(c(1:2))$p.value, t.test(c(3:4))$p.value)
# better to explicitly provide name
nc(T1 = t.test(c(1:2))$p.value,
T2 = t.test(c(3:4))$p.value)
# vector of unnamed inputs
A <- c(5,4,3,2,1)
B <- c(100, 200)
nc(A, B, C) # A's and B's numbered uniquely
c(A, B, C) # compare
nc(beta=A, B, C) # replacement of object name
# retain names attributes (but append object name, when appropriate)
names(A) <- letters[1:5]
nc(A, B, C)
nc(beta=A, B, C)
nc(A, B, C, use.names=TRUE)
# mix and match if some named elements work while others do not
c( nc(A, B, use.names=TRUE), nc(C))
## Not run:
# error, 'b' appears twice
names(B) <- c('b', 'b2')
nc(A, B, C, use.names=TRUE)
## End(Not run)
# List input
A <- list(1)
B <- list(2:3)
C <- list('C')
names(C) <- 'LetterC'
# compare the following
c(A, B, C) # unnamed
nc(A, B, C) # named
nc(this=A, B, C) # respects override named (same as c() and list() )
nc(this=A, B, C, use.names = TRUE) # preserve original name
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.