{"id":130303,"date":"2020-07-03T18:02:00","date_gmt":"2020-07-03T10:02:00","guid":{"rendered":"http:\/\/4563.org\/?p=130303"},"modified":"2020-07-03T18:02:00","modified_gmt":"2020-07-03T10:02:00","slug":"%e8%af%b7%e9%97%ae%e6%9c%89%e6%b2%a1%e6%9c%89%e4%bc%9ar%e8%af%ad%e8%a8%80%e7%9a%84%e5%a4%a7%e4%bd%ac-%e4%b8%80%e4%b8%aa%e8%84%9a%e6%9c%ac%e5%b0%8f%e4%bf%ae%e6%94%b9","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=130303","title":{"rendered":"\u8bf7\u95ee\u6709\u6ca1\u6709\u4f1aR\u8bed\u8a00\u7684\u5927\u4f6c \u4e00\u4e2a\u811a\u672c\u5c0f\u4fee\u6539"},"content":{"rendered":"\n<p>  \t\t\t\t\t<strong>zmia<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3>\u8bf7\u95ee\u6709\u6ca1\u6709\u4f1aR\u8bed\u8a00\u7684\u5927\u4f6c \u4e00\u4e2a\u811a\u672c\u5c0f\u4fee\u6539<\/h3>\n<p>  \t\t \u672c\u5e16\u6700\u540e\u7531 zmia \u4e8e 2020-7-3 18:06 \u7f16\u8f91 <\/p>\n<p> #### table1 &#8212;-<br \/>  setwd(tabPath)<br \/>  # https:\/\/cran.r-project.org\/web\/packages\/table1\/vignettes\/table1-examples.html<br \/>  # \u53d8\u91cf\u540d\u8bbe\u7f6e<br \/>  labels = list(<br \/>  &nbsp; &nbsp; # variables = list(age_at_initial_pathologic_diagnosis = &quot;Age (year)&quot;,<br \/>  &nbsp; &nbsp; #&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;gender = &quot;Gender&quot;, <br \/>  &nbsp; &nbsp; #&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;relative_family_cancer_history = &quot;Family history of cancer&quot;,<br \/>  &nbsp; &nbsp; #&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;pathologic_stage = &quot;TNM stage&quot;,&#8230;),<br \/>  &nbsp; &nbsp; variables = labs_list, # \u7b49\u540c\u4e8e\u4e0a\u793a\u8bbe\u7f6e<br \/>  &nbsp; &nbsp; groups = list(&quot;&quot;, paste0(symbol, &quot; Expression&quot;), &quot;&quot;)) # \u8868\u5934\u5927\u7ec4<\/p>\n<p>  # \u8bbe\u7f6e\u51fd\u6570\u7528\u4e8e\u6dfb\u52a0p\u503c\u5217<br \/>  rndr = function(x, name, &#8230;) {<br \/>  &nbsp; &nbsp; # \u5c06data_for_table1\u66ff\u6362\u4e3a\u771f\u5b9e\u7684\u6570\u636e<br \/>  &nbsp; &nbsp; if (length(x) == 0) {<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;y &lt;- data_for_table1[]<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;s &lt;- rep(&quot;&quot;, length(render.default(x=y, name=name, &#8230;)))<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;if (is.numeric(y)) {<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;p &lt;- t.test(y ~ data_for_table1[,symbol])$p.value# symbol\u4e3a\u7528\u4e8e\u5206\u7ec4\u7684\u57fa\u56e0\u540d<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;} else {<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;p &lt;- chisq.test(table(y, droplevels(data_for_table1[,symbol])))$p.value<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;}<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;s &lt;- sub(&quot;&lt;&quot;, &quot;&amp;lt;&quot;, format.pval(p, digits=3, eps=0.001))<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;s<br \/>  &nbsp; &nbsp; } else {<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;render.default(x=x, name=name, &#8230;)<br \/>  &nbsp; &nbsp; }<br \/>  }<br \/>  rndr.strat &lt;- function(label, n, &#8230;) {<br \/>  &nbsp; &nbsp; ifelse(n==0, label, render.strat.default(label, n, &#8230;))<br \/>  }<\/p>\n<p>  # \u8bbe\u7f6e\u5206\u7ec4<br \/>  levels(data_for_table1[,symbol]) = c(&quot;High&quot;,&quot;Low&quot;,&quot;P-value&quot;)<br \/>  strata = c(list(Total = data_for_table1), split(data_for_table1, data_for_table1[,symbol]))<\/p>\n<p>  # \u663e\u793a\u8868\u683c(\u53ef\u76f4\u63a5\u62f7\u8d1d\u5230word\u91cc\u4fee\u6539, \u6216\u5728Viewer\u7a97\u53e3Export -&gt; Save as Web Page&#8230;)<br \/>  tab1 = table1(strata, labels, groupspan = c(1, 2, 1), droplevels = F, render = rndr, render.strat = rndr.strat)<\/p>\n<p>  \u9700\u8981\u4ece https:\/\/cran.r-project.org\/web\/packages\/table1\/vignettes\/table1-examples.html \u4e2d\u62f7\u8d1d\u4e0e\u539f\u811a\u672c\u76f8\u540c\u7684 rndr \u548c rndr.strat \u51fd\u6570\u66ff\u6362\u6389\u4e0a\u9762\u4ee3\u7801\u4e2d\u7684\u51fd\u6570\uff0c\u5e76\u4fee\u6539\u51fd\u6570\u4f53\u5185\u76f8\u5e94\u7684\u53d8\u91cf\u540d\u79f0\u3002<\/p>\n<p>  loc\u5927\u4f6c\u591a\uff0c\u7279\u6765\u6c42\u52a9\uff0c\u672c\u4eba\u5bf9\u4ee3\u7801\u4e00\u7a8d\u4e0d\u901a\uff0c10\u5143\u5c0f\u7ea2\u5305\u4e0d\u6210\u656c\u610f\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>heihai<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\t\u6211\u4e5f\u5bf9\u4ee3\u7801\u4e00\u7a8d\u4e0d\u901ahttps:\/\/cdn.jsdelivr.net\/gh\/hishis\/forum-master\/public\/images\/patch.gif\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>minsc<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\tRust\uff1f\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>\u8425\u517b\u5feb\u7ebf<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\t\u522b\u8bf4\u94b1\u7684\u4e8b\u513f\uff0c\u4f1a\u7684\u770b\u5230\u4e86\u80af\u5b9a\u4f1a\u7422\u78e8\uff0c loc\u7684\u6280\u672f\u5927\u4f6c\u4ece\u6765\u4e0d\u542b\u7cca\u3002\u4f60\u52a0\u4e0a\u5341\u5757\u94b1\u8fd9\u9898\u5c31\u65e0\u89e3\u4e86\t\t\t  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>zmia \u5927\u4f6c\u6709\u8bdd\u8bf4 : \u8bf7\u95ee\u6709\u6ca1&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/130303"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=130303"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/130303\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=130303"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=130303"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=130303"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}