0

I am conducting cross tabulation between two variables using the "prop.table()" function. How can I label the row, columns, and title to increase readability. code below.

prop.table(table(hl$high, hl$midwest),1) * 100

neilfws
  • 32,751
  • 5
  • 50
  • 63
  • 2
    Hi Tyler, it would help to answer your question if you had reproducible example in it, have a look at some answers here: https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Bulat Oct 13 '19 at 22:01

1 Answers1

0

It's a data.frame you can do whatever you like

  z <- prop.table(table(mtcars$cyl , mtcars$am),1) * 100
    rownames( z ) <- c( "Four","Six","Eight")
    colnames( z) <- c("Does Not Have","Does Have")
    print( z)
MatthewR
  • 2,660
  • 5
  • 26
  • 37
  • It's not a `data.frame`, it's a `table`, but `rownames()` and `colnames()` work for `table`s as well. By default, the rownames and colnames are filled in too. I think OP is asking about the labels overall, as you'd get with `table(mtcars[c("cyl","am")])` – thelatemail Oct 13 '19 at 23:05