creating-matrix-with-factors

Problem: Define row- and colum-names directly rather than evoking rownames() and colnames() afterwards. one-liners are elegant

my.matrix <- matrix(c(31, 69), nrow = 1,
                               dimnames = list(c("Röstar på moderaterna"),
                                               c("ja", "nej")
                                              )
                    )

Plot it.

barplot(my.matrix, ylim = c(0, 100),
                   main = "Skulle du rösta på moderaterna, om det vore val idag?")

comments powered by Disqus


Back to the index

Blog roll

R-bloggers, Debian Weekly
Valid XHTML 1.0 Strict [Valid RSS] Valid CSS! Emacs Muse Last modified: oktober 17, 2019