Question about avoiding command usage
Hi! Does that mean that if we are using the "dimnames=list" function then we can totally avoid usng commands like rownames and colnames? also the example showed inthe video also suggests that by writing code like this we can also avoid command cbind, is my understanding correct?
Yep, totally. However, when using dimnames() you must always define both row and column names in the list; that's the structure of the function. Colnames() and rownames() are just a way to avoid assigning names to one of these dimensions.
Moving on. Cbind() is a good command to know and use -- I would not particularly avoid using it. Imagine you want to create a matrix that has 15 columns and 10 rows. Personally, I find that unpleasant to do as a one-liner; it also makes for difficult to read code (if you're sharing your work with s/o).
But, yes, you are correct -- you could avoid using cbind() altogether if you decide to. It would save time, especially when creating smaller objects.
And of course, the more comfortable you get with R, the more often you'll be using longer commands that do multiple things, so that's a good thing to wonder about! We talk about this again further on when we learn about the pipe operator.