This is probably a very basic question... I have a simple dataframe with different observations per course. I want R to return the number of rows (in my case equal to the number of observations) per course.
So for example:
DF <- structure(list(age = c(36, 21, 20, 32, 24), course = c("AERO",
"AERO", "CREDIT", "CREDIT", "SOLAR")), .Names = c("age", "course"), class = "data.frame", row.names = c(NA,
-5L))
Then I want to have something like
nrow(DF, by=course)
.. to return the number of rows per course. I know that nrow(DF, by=course)
does not exist, but is there anything else?
I have used subsets, but then I have to define each subset.