1
x=rbind(rep(1:3),rep(1:3))
x
     [,1] [,2] [,3]
[1,]    1    2    3
[2,]    1    2    3

How is it possible to remove the braces and values inside with comma? I try make.row.names = FALSE but this does not work

LyzandeR
  • 37,047
  • 12
  • 77
  • 87
bvowe
  • 3,004
  • 3
  • 16
  • 33
  • Possible duplicate: https://stackoverflow.com/questions/26906557/print-a-matrix-without-row-and-column-indices – qdread Mar 28 '19 at 12:33

2 Answers2

1

You can do it with rownames and colnames:

colnames(x) <- 1:3
rownames(x) <- 1:2
x
#  1 2 3
#1 1 2 3
#2 1 2 3
LyzandeR
  • 37,047
  • 12
  • 77
  • 87
1

You're probably confusing matrices with data frames?

x <- rbind(rep(1:3), rep(1:3))
x
#      [,1] [,2] [,3]
# [1,]    1    2    3
# [2,]    1    2    3

The display is perfectly fine, since x is a matrix:

class(x)
# [1] "matrix"

You could change dimnames like so

dimnames(x) <- list(1:nrow(x), 1:ncol(x))
x
#   1 2 3
# 1 1 2 3
# 2 1 2 3

However, probably you want a data frame.

x <- as.data.frame(rbind(rep(1:3), rep(1:3)))
x
#   V1 V2 V3
# 1  1  2  3
# 2  1  2  3

class(x)
# [1] "data.frame"
jay.sf
  • 60,139
  • 8
  • 53
  • 110