(Using mtcars & iris for reproducibility)

I have created a R function `get_col_info` to find summary of data which is as per below:

1. If column is `numeric/integer/double` then get min,max,mean
2. If column is `character/factor` then get count of unique values & unique values

```
 get_col_info <- function(data,col_name) {  

  c_name <- c(col_name)
  s <- data[,c_name]
  type <- typeof(s)

  if(type %in% c("numeric","double","integer")){
   min <- min(s)
   max <- max(s)
   mean <- mean(s)
   aa <- list(min=min, max=max,mean=mean)
   return(aa)
  }

 if(type %in% c("character","factor")){
  uni <- unique(s)
  len <- length(uni)
  aa <- list(n_values=len,unique_values=c(uni))
  return(aa)}
 }

get_col_info(mtcars, "mpg")
get_col_info(iris, "Petal.Width")
get_col_info(iris, "Species")

```

The first two runs perfect, third one gives an error, not sure why ?

However, the main query is now I want to run this function for all column name at once, something like `sapply(iris,mean)` but I am not sure how to do that because the function takes in dataframe & column name. I tried doing this but it gives me an error

```
sapply(iris,get_col_info(iris,names(iris)))

Error in match.fun(FUN) : 
  'get_col_info(iris, names(iris))' is not a function, character or symbol

```

Both apply & purrr solutions are welcome. I am also looking for someone to tell me how could I have written my function better, I suspect c\_name that I created is not the ideal way to catch column names.