I am using this function I wrote to apply over all the columns in the flights data frame, from nycflights13. I want to remove the NA values that occur in each row, yet keep the same structure as the output shows. How would I go about doing that?
checker <- function(x){
if(is.numeric(x)){
max.x <- max(x, na.rm = TRUE)
min.x <- min(x, na.rm = TRUE)
vectorlist <- list(max=max.x, min=min.x)
return(vectorlist)
} else vectorlist <- list(max = NA, min = NA)
return(vectorlist)
}
flightlist <- t(sapply(flights, checker))
flightlist