when I run the following commands
all_trips <- rbind(q1_2019,q2_2019, q3_2019, q4_2019)
colnames(all_trips)
colnames gives me NULL. how to deal with it?
when I run the following commands
all_trips <- rbind(q1_2019,q2_2019, q3_2019, q4_2019)
colnames(all_trips)
colnames gives me NULL. how to deal with it?
colnames is used to set the names to columns of a matrix, as we can read here: https://www.geeksforgeeks.org/naming-rows-and-columns-of-a-matrix-in-r-programming-rownames-and-colnames-function/
An example is given as
A = matrix(c(1, 2, 3, 4, 5, 6, 7, 8, 9), 3, 3, byrow = TRUE)
# Calling colnames() Function
colnames(A) <- letters[1:3]
See the part of ** <- letters[1:3]** which is specifying the actual column names of the matrix in the example. Yet, you do not specify it. For instance, if you want to specify the first four letters of the alphabet to your matrix, then you can do it like
colnames(all_trips) <- letters[1:4]