5 In R, you may always check the code of a function by entering its name without the quotation marks. By doing this, you can observe how NCOL and ncol differ from one another:
NCOL
function # (x)
If length(d-dim(x)) > 1L, then d[2L] is used. else 1L
#
#
ncol
function # (x)
# dim(x)[2L]
#
#
While NCOL checks to see if the argument only has one dimension, in which case it returns 1, ncol always returns the second dimension of the argument.
Transform data into actionable insights with our Data Analyst Certification – Enroll today!