I am trying to create a data frame containing multiple cor.test results.
I have used the apply method to generate a list of multiple results for my data set:
tests<-apply(data[,-1],2,cor.test,data$somevariable)
I've then tried to turn that list into a data frame using do.call and rbind:
df<-do.call(rbind,tests)
Here is the structure of the data after this point:
structure(list(c(t = 9.73527458723168), c(t = 11.6358332145994), 
    c(t = -8.41342945363561), c(t = 4.76930273088914), c(t = 5.38274340720866), 
    c(t = 1.36141073255796), 2.0305145351559e-19, 1.10699280065747e-25, 
    2.25755786735353e-15, 3.01264916719032e-06, 1.58134326207236e-07, 
    0.174506476001015, structure(c(0.41422989714479, 0.5904698126317
    ), conf.level = 0.95), structure(c(0.490934145176199, 0.649810665047493
    ), conf.level = 0.95), structure(c(-0.542907553904067, -0.354506442300791
    ), conf.level = 0.95), structure(c(0.164439228019406, 0.383047613908603
    ), conf.level = 0.95), structure(c(0.198753649224564, 0.412910725931687
    ), conf.level = 0.95), structure(c(-0.0365206469491267, 0.198474167071758
    ), conf.level = 0.95)), .Dim = c(6L, 3L), .Dimnames = list(
    c("hour", "temp_C", "humidity", "wind_speed_ms", "visibility_10m", 
    "dew_point_temp_C"), c("statistic", "p.value", "conf.int"
    )))
The result is almost what I am after. However, there are two problems:
1.) the return is a list as opposed to a data frame. Using as.data.frame(df) returns a data frame in which all values appear replaced with their type i.e. <dbl[1]>.
2.) Values for conf.int column seem to be condensed to numeric,2 as opposed to displaying both values.
I feel I am a step away from where I need to be here. I have tried to use bind_rows(df,.id='column_label') as a final step but receive the error "Argument 17 must have names"
Any help on getting the correct dataframe of cor.test results would be much appreciated.
 
    