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
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
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
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"