I’m trying to learn Julia by replicating simple R code in Julia but I’m not even able to create a toy example
Let me ask some simple question.
In R there is a function letters, which gives you a vector with all letters or a subset of it, then you don’t need to type them. There is also LETTERS for uppercase.
letters[1:10] a, b, c, d, e, f, g, h, i, j
How can we get all letters in Julia?
What is the easiest way (and the fastest) to create a vector (or whichever prefered Julia container) with all combinations of letters and/or numbers?
nn <- 3 mynames <- CJ(letters[1:nn], paste0( rep(letters[1:nn],1:nn), "_20", sprintf("%02d",sequence(1:nn))))[,paste0(V1,V2)]
Here I’m using sprintf in order to be able to run it with longer numbers and get a valid date. And you can use expand.grid instead of CJ but is much slower.
That code produces this vector:
aa_2001, ab_2001, ab_2002, ac_2001, ac_2002, ac_2003, ba_2001, bb_2001, bb_2002, bc_2001, bc_2002, bc_2003, ca_2001, cb_2001, cb_2002, cc_2001, cc_2002, cc_2003
How can I do it with Julia?