In R, what is the fastest way(shortest code) to print multiplication table? The functions seq rep and the bind functions help, but I'm looking for the shortest line(s) of code to do this.
rbind("1\'s"=1:12, "2\'s"=seq(2,24,2), "3\'s"=seq(3,36,3),
"4\'s"=seq(4,48,4), "5\'s"=seq(5,60,5), "6\'s"=seq(6,72,6))
Prints the 1's through 6's going across (horizontally). Anyone know how to perform this in a more compact way?
A shortcut for
outer(1:6, 1:12, "*")
:You could make slightly more compact by using
paste0(1:6, "'s")
This seems a slight improvement: