why nrow(dataframe) and length(dataframe) in r give different results?

I have a ordered data frame and want to know the number of the last row.

data_ranking <- reduced_data[order(reduced_data$outcome,reduced_data$hospital,na.last=NA),]
nobs <- nrow(data_ranking)

gives me different results of

data_ranking <- reduced_data[order(reduced_data$outcome,reduced_data$hospital,na.last=NA),]
nobs <- length(data_ranking)

I would like to understand why is that. It seems that nrowgives me the answer I’m looking for, but I don’t understand why.

Leave a Comment