added na.rm parameter to filter out the columns with only NA values.