I have a dataframe, and I want to produce a table of summary statistics including number of valid numeric values, mean and sd by group for each of three columns. I can\'t seem
What are "blank values" and "text values"? If you have numeric vector then you could have NA's (is.na()
), Inf's (is.infinite()
), NaN's (is.nan()
) and "valid" numeric values.
For "valid" numeric values (in the sense above) you could use is.finite()
:
is.finite(c(1,NA,Inf,NaN))
# [1] TRUE FALSE FALSE FALSE
sum( is.finite(c(1,NA,Inf,NaN)) )
# [1] 1
So colSums(is.numeric(x))
could be done like colSums(is.finite(x))
.