I'm trying to run a Pearson correlation test for every two pairs of fields in each dataframe in a list of dataframes.
data(mtcars)
split_mtcars = split (mtcars, f= mtcars$gear)
lapply (split_mtcars,FUN = function (x)
rcorr(as.matrix(split_mtcars$x %>% select (-gear,-am)))) #remove `gear` and `am` from matrix
I'm getting the following error:
Error in UseMethod("select") :
no applicable method for 'select' applied to an object of class "NULL"
When I try to avoid using select:
lapply (split_mtcars,FUN = function (x) rcorr(as.matrix(split_mtcars$x)))
I get the following error:
Error in array(x, c(length(x), 1L), if (!is.null(names(x))) list(names(x), :
'data' must be of a vector type, was 'NULL'