I want to create a table and set the names to it but it does not work as expected. Actually, I can't find what is wrong
arr <- array(dim = c(1,5))
names(arr) <- c("Year", "Month", "Day", "Name", "Surname")
I want to create a table and set the names to it but it does not work as expected. Actually, I can't find what is wrong
arr <- array(dim = c(1,5))
names(arr) <- c("Year", "Month", "Day", "Name", "Surname")
It is a matrix
and matrix have dimnames
. So, either we provide the dimnames
as a list
when the array
is initialized
arr <- array(dim = c(1,5), dimnames = list(NULL,
c("Year", "Month", "Day", "Name", "Surname")))
or assign the column names with colnames
colnames(arr) <- c("Year", "Month", "Day", "Name", "Surname")
arr
# Year Month Day Name Surname
#[1,] NA NA NA NA NA