簡體   English   中英

將多個配對 t 檢驗的結果保存到 R 中的 CSV

[英]Saving results of multiple paired t-tests to CSV in R

不可能將這樣的對象導出為可讀的內容(.xls 或 csv)。 我已經嘗試了 unlist() 的一些選項,但它不起作用

有一種半自動化的方法可以輕松放置它嗎? 是否有任何提示需要所有關於 d.frame str 的警告?

list(ttest_00_compare_ttest_66 = list(ttest_results_for_peso1 = structure(list(
    statistic = c(t = 21.4249656343657), parameter = c(df = 405), 
    p.value = 1.25024210970737e-68, conf.int = structure(c(4.05914117575371, 
    4.87928246956648), conf.level = 0.95), estimate = c(`mean of the differences` = 4.4692118226601), 
    null.value = c(`difference in means` = 0), stderr = 0.208598319312656, 
    alternative = "two.sided", method = "Paired t-test", data.name = "left_frame[[.x]] and right_frame[[.x]]"), class = "htest"), 
    ttest_results_for_cintura1 = structure(list(statistic = c(t = 19.4572382569541), 
        parameter = c(df = 394), p.value = 1.39672720591824e-59, 
        conf.int = structure(c(4.0123101442803, 4.91427213420071
        ), conf.level = 0.95), estimate = c(`mean of the differences` = 4.46329113924051), 
        null.value = c(`difference in means` = 0), stderr = 0.229389756156443, 
        alternative = "two.sided", method = "Paired t-test", 
        data.name = "left_frame[[.x]] and right_frame[[.x]]"), class = "htest"), 
    ttest_results_for_tasis2_e = structure(list(statistic = c(t = 5.73924157171437), 
        parameter = c(df = 386), p.value = 1.92575514222722e-08, 
        conf.int = structure(c(2.73331928206763, 5.58192619596855
        ), conf.level = 0.95), estimate = c(`mean of the differences` = 4.15762273901809), 
        null.value = c(`difference in means` = 0), stderr = 0.724420236901818, 
        alternative = "two.sided", method = "Paired t-test", 
        data.name = "left_frame[[.x]] and right_frame[[.x]]"), class = "htest"), 
    ttest_results_for_tadias2_e = structure(list(statistic = c(t = 5.14230494122335), 
        parameter = c(df = 386), p.value = 4.32416774320438e-07, 
        conf.int = structure(c(1.76359180295719, 3.94700251228829
        ), conf.level = 0.95), estimate = c(`mean of the differences` = 2.85529715762274), 
        null.value = c(`difference in means` = 0), stderr = 0.555256288815783, 
        alternative = "two.sided", method = "Paired t-test", 
        data.name = "left_frame[[.x]] and right_frame[[.x]]"), class = "htest"), 
    ttest_results_for_p17_total = structure(list(statistic = c(t = -22.4194079348015), 
        parameter = c(df = 401), p.value = 9.57084254025044e-73, 
        conf.int = structure(c(-3.88537057270109, -3.25890803426408
        ), conf.level = 0.95), estimate = c(`mean of the differences` = -3.57213930348259), 
        null.value = c(`difference in means` = 0), stderr = 0.159332454892244, 
        alternative = "two.sided", method = "Paired t-test", 
        data.name = "left_frame[[.x]] and right_frame[[.x]]"), class = "htest"), 
    ttest_results_for_geaf_tot = structure(list(statistic = c(t = -4.68460084544805), 
        parameter = c(df = 405), p.value = 3.83559659933986e-06, 
        conf.int = structure(c(-787.190610756831, -321.810916336765
        ), conf.level = 0.95), estimate = c(`mean of the differences` = -554.500763546798), 
        null.value = c(`difference in means` = 0), stderr = 118.366704408893, 
        alternative = "two.sided", method = "Paired t-test", 
        data.name = "left_frame[[.x]] and right_frame[[.x]]"), class = "htest"), 
    ttest_results_for_glucosa = structure(list(statistic = c(t = 4.65396507660859), 
        parameter = c(df = 389), p.value = 4.47235135802037e-06, 
        conf.int = structure(c(2.74112736865063, 6.75118032365707
        ), conf.level = 0.95), estimate = c(`mean of the differences` = 4.74615384615385), 
        null.value = c(`difference in means` = 0), stderr = 1.01980865090901, 
        alternative = "two.sided", method = "Paired t-test", 
        data.name = "left_frame[[.x]] and right_frame[[.x]]"), class = "htest"), 
    ttest_results_for_albumi = structure(list(statistic = c(t = 2.23473479324875), 
        parameter = c(df = 389), p.value = 0.0260019839763132, 
        conf.int = structure(c(0.00399799504721955, 0.0625148254656009
        ), conf.level = 0.95), estimate = c(`mean of the differences` = 0.0332564102564102), 
        null.value = c(`difference in means` = 0), stderr = 0.0148815914787202, 
        alternative = "two.sided", method = "Paired t-test", 
        data.name = "left_frame[[.x]] and right_frame[[.x]]"), class = "htest"), 
    ttest_results_for_coltot = structure(list(statistic = c(t = 2.51608624443565), 
        parameter = c(df = 389), p.value = 0.0122683258984958, 
        conf.int = structure(c(0.893439124393901, 7.28091984996507
        ), conf.level = 0.95), estimate = c(`mean of the differences` = 4.08717948717949), 
        null.value = c(`difference in means` = 0), stderr = 1.62441947139862, 
        alternative = "two.sided", method = "Paired t-test", 
        data.name = "left_frame[[.x]] and right_frame[[.x]]"), class = "htest"), 
    ttest_results_for_hdl = structure(list(statistic = c(t = -4.54248449775128), 
        parameter = c(df = 389), p.value = 7.42768982387346e-06, 
        conf.int = structure(c(-2.43212119510371, -0.96275059976808
        ), conf.level = 0.95), estimate = c(`mean of the differences` = -1.6974358974359), 
        null.value = c(`difference in means` = 0), stderr = 0.373680063911324, 
        alternative = "two.sided", method = "Paired t-test", 
        data.name = "left_frame[[.x]] and right_frame[[.x]]"), class = "htest"), 
    ttest_results_for_ldl_calc = structure(list(statistic = c(t = 2.59106690773786), 
        parameter = c(df = 359), p.value = 0.009958077249337, 
        conf.int = structure(c(0.870313797652815, 6.35190842456941
        ), conf.level = 0.95), estimate = c(`mean of the differences` = 3.61111111111111), 
        null.value = c(`difference in means` = 0), stderr = 1.39367729190128, 
        alternative = "two.sided", method = "Paired t-test", 
        data.name = "left_frame[[.x]] and right_frame[[.x]]"), class = "htest"), 
    ttest_results_for_trigli = structure(list(statistic = c(t = 5.36682824520075), 
        parameter = c(df = 389), p.value = 1.37983046152459e-07, 
        conf.int = structure(c(10.0215848527913, 21.609184377978
        ), conf.level = 0.95), estimate = c(`mean of the differences` = 15.8153846153846), 
        null.value = c(`difference in means` = 0), stderr = 2.94687735340281, 
        alternative = "two.sided", method = "Paired t-test", 
        data.name = "left_frame[[.x]] and right_frame[[.x]]"), class = "htest"), 
    ttest_results_for_hba1c = structure(list(statistic = c(t = 8.33170299894741), 
        parameter = c(df = 285), p.value = 3.40154253670161e-15, 
        conf.int = structure(c(0.227070256948141, 0.367545127667244
        ), conf.level = 0.95), estimate = c(`mean of the differences` = 0.297307692307692), 
        null.value = c(`difference in means` = 0), stderr = 0.0356839042804638, 
        alternative = "two.sided", method = "Paired t-test", 
        data.name = "left_frame[[.x]] and right_frame[[.x]]"), class = "htest"), 
    ttest_results_for_i_hucpeptide = structure(list(statistic = c(t = 5.90101499361481), 
        parameter = c(df = 286), p.value = 1.01987286390723e-08, 
        conf.int = structure(c(73.6939317936256, 147.460284234249
        ), conf.level = 0.95), estimate = c(`mean of the differences` = 110.577108013937), 
        null.value = c(`difference in means` = 0), stderr = 18.7386590499409, 
        alternative = "two.sided", method = "Paired t-test", 
        data.name = "left_frame[[.x]] and right_frame[[.x]]"), class = "htest"), 
    ttest_results_for_i_hughrelin = structure(list(statistic = c(t = 1.58540602691369), 
        parameter = c(df = 286), p.value = 0.113979140715432, 
        conf.int = structure(c(-5.15297611977527, 47.8264255971272
        ), conf.level = 0.95), estimate = c(`mean of the differences` = 21.336724738676), 
        null.value = c(`difference in means` = 0), stderr = 13.4582084188315, 
        alternative = "two.sided", method = "Paired t-test", 
        data.name = "left_frame[[.x]] and right_frame[[.x]]"), class = "htest"), 
    ttest_results_for_i_hugip = structure(list(statistic = c(t = 1.02337156349601), 
        parameter = c(df = 286), p.value = 0.306997017640596, 
        conf.int = structure(c(-106.190510640337, 336.203960117689
        ), conf.level = 0.95), estimate = c(`mean of the differences` = 115.006724738676), 
        null.value = c(`difference in means` = 0), stderr = 112.380223216086, 
        alternative = "two.sided", method = "Paired t-test", 
        data.name = "left_frame[[.x]] and right_frame[[.x]]"), class = "htest")))
       

在此先感謝您的幫助

x成為您的示例數據。 然后你可以這樣做:

library(tidyverse)
library(broom)
x[[1]] %>%
  map(tidy) %>%
  enframe() %>%
  unnest(value) %>%
  write_csv("tests.csv")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM