> is.numeric_data.frame=function(x)all(sapply(x,is.numeric))
> is.numeric_data.frame(d1[[5]])
[1] TRUE
Why
d1is a list, therefore d1[5]is a list of length 1, and in this case contains a data.frame. to get a data frame use d1[[5]].
Even if a data frame contains numeric data, it is not numeric:
> x = data.frame(1:5,6:10)
> is.numeric(x)
[1] FALSE
The individual columns in the data frame are either numeric or non-numeric. For instance:
> z <- data.frame(1:5,letters[1:5])
> is.numeric(z[[1]])
[1] TRUE
> is.numeric(z[[2]])
[1] FALSE
, , all sapply:
> sapply(z,is.numeric)
X1.5 letters.1.5.
TRUE FALSE
> all(sapply(z,is.numeric))
[1] FALSE
> all(sapply(x,is.numeric))
[1] TRUE
:
> is.numeric_data.frame=function(x)all(sapply(x,is.numeric))
> is.numeric_data.frame(d1[[5]])
[1] TRUE