I guess this is rather trivial. Given, e.g.,
L={1,2}
what are some common efficient ways to obtain
L
(*{1,2,1,2,1,2}*)
that is, the list concatenated three times with itself and obtained the new value. Thanks in advance.
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityThere is a dedicated function in R:
Needs["RLink`"]
InstallR[]
REvaluate["rep(c(1,2),5)"]
(* {1., 2., 1., 2., 1., 2., 1., 2., 1., 2.} *)
Another possibility is to use length.out
:
REvaluate["rep(c(1,2),length.out=5)"]
(* {1., 2., 1., 2., 1.} *)
Catenate@ConstantArray[L, 3]
? $\endgroup$3*L
to get the desired output:-)! $\endgroup$