Question:
I want to create a table which includes(Mean, SD and Range) for stop types. I used the following but I got two problems clear in the result table:The labels of the first row (Mean) and the second row (SD) are missing. How can I include them with keeping the values rounded?
I want to create a row for (Range) to include (Min:Max) together, separated by a colon. It gives wrong results. how can I correct that?
Answer:
- You can use named arguments for rows in
rbind
to name the rows. - If you want the Range to be two numbers separated by a colon, then you can use
paste
, but the entire table will become a character matrix. This may not be what you want. However, you can still print it nicely usingnoquote
Data used (taken from question)
Mean <- c(b = -117, d = -130, g = -117, k = 84, p = 55, t = 66) SD <- c(b = 37, d = 33, g = 28, k = 18, p = 12, t = 18) Min <- c(b = -220, d = -219, g = -200, k = 50, p = 39, t = 40) Max <- c(b = -60, d = -70, g = -42, k = 118, p = 84, t = 111) [/code]
If you have better answer, please add a comment about this, thank you!