{"id":2569,"date":"2022-08-30T12:22:52","date_gmt":"2022-08-30T04:22:52","guid":{"rendered":"http:\/\/cnliutz.uicp.io\/?p=2569"},"modified":"2022-08-30T12:22:52","modified_gmt":"2022-08-30T04:22:52","slug":"r%e8%af%ad%e8%a8%80%e6%96%b9%e5%b7%ae%e5%88%86%e6%9e%90","status":"publish","type":"post","link":"http:\/\/g1n29wqq.ipyingshe.net:5347\/?p=2569","title":{"rendered":"R\u8bed\u8a00\u65b9\u5dee\u5206\u6790"},"content":{"rendered":"\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<pre class=\"wp-block-code\"><code>---\ntitle: \"\u65b9\u5dee\u5206\u6790 analysis\"\nauthor:\n  - Liu tiezhu\ndate: '2022-08-29'\ndocumentclass: ctexart\nkeywords:\n  - \u4e2d\u6587\n  - R Markdown\noutput:\n  rticles::ctex:\n    fig_caption: yes\n    number_sections: yes\n    toc: yes\n---\n\n```{r setup, include=FALSE}\nknitr::opts_chunk$set(echo = TRUE)\n```\n\n## Analysis with R \n- Explore\n- clean\n- Manipulate\n- Describe and summarise\n- Analyse\n### Analyse your data\n## ANOVA coding\n``` {r}\nlibrary(tidyverse)\nlibrary (patchwork)\nlibrary(gapminder)  #life expect in difference area\nlibrary(forcats)\n#data()\nhead(gapminder)\n# Create a data set to work with\ngapdata &lt;-  gapminder %>%\nfilter(year ==2007&amp;\ncontinent %in% c(\"Americas\",\"Europe\",\"Asia\")) %>%\nselect(continent,lifeExp)\n#Take a look at the distribution of means\ngapdata %>%\ngroup_by(continent) %>%\nsummarise(Mean_life=mean(lifeExp)) %>%\narrange(Mean_life)\n#Research question:\n# Is the life expectancy  in these three continents\n# Research question: Is the life expectancy in these three continents different\n# Hypothesis testing: HO:Mean life expectancy is the same\n#                     HI:Mean life expectancy is not the same\n# observation:\n# Difference in mean is observed in the sample data,but is this statistically \n#  significant (alpha 0.05)    \n#  Create ANOVA mode 1  \ngapdata  %>%\naov(lifeExp ~ continent,data =.) %>%\nsummary()\naov_model &lt;- gapdata  %>%\naov(lifeExp ~ continent,data =.)\n\n# Is this significance being driven by a particular continent?  \ngapdata %>%\naov(lifeExp ~ continent,data = .) %>%\nTukeyHSD() %>%\nplot()\nTukeyHSD(aov_model)\n\n#The difference between Asia and the Americas\n#has an adjusted p value of 0.14 (not significant)\n#and a 95%cI that overlaps 0\n\n```<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[],"class_list":["post-2569","post","type-post","status-publish","format-standard","hentry","category-r"],"_links":{"self":[{"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts\/2569","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2569"}],"version-history":[{"count":0,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts\/2569\/revisions"}],"wp:attachment":[{"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2569"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2569"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2569"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}