The task is to write the shortest R statement to count the cells (rows * cols) in an instance of the R type
numeric data.frame. For example, the
data.frame which would be displayed as
a b c 1 1 2000 NA 2 2 2000 NA 3 3 2000 1 4 4 2000 Inf
has 12 cells.
data.frame is supplied in variable
x. You may assume that it contains only numbers, boolean,
Inf (no strings and factors).
Example code to construct your own
x <- merge(data.frame(a = 1:100), merge(data.frame(b = 2000:2012), data.frame(c = c(NA, 10, Inf, 30))))
The expected output is 15600.
Curious if someone can beat my solution :-) I don't want to take the fun from you so I will not reveal it now, I will only show you md5sum of my solution so that you later trust me in case you invent the same :-)