Visualizing the Data

setwd("/Users/macdovps/Documents/R_Classes")
data <- read.csv("LiveLongerData.csv")
print(data)
##                                                        Factor
## 1                                                     Smoking
## 2                                                Sitting Down
## 3                                           Too much sleeping
## 4                                               More Optimism
## 5                                                   More Pets
## 6                            more professional responsibility
## 7                                              Healthy Eating
## 8                                                    Red Meat
## 9                                       Alcohol (heavy abuse)
## 10                                                City living
## 11                                             Mental Illness
## 12                                                    Obesity
## 13                                      More Health Checks #2
## 14                                    Living at high altitude
## 15                                              Good marriage
## 16                                                  Less Food
## 17                                            More Meditation
## 18                                        Avoid heart disease
## 19 a lifestyle of non-smoking, exercising, and healthy eating
## 20                             Spending more time with women 
## 21                                               Avoid Cancer
## 22                                              More Exercise
## 23                                           A little alcohol
## 24                                More conscientious & stable
## 25                                                    Orgasms
## 26                                              A little wine
## 27                                                 More Money
## 28                                              being a woman
## 29                                         More close Friends
## 30                                Greater Faith (churchgoing)
## 31                                             Country living
## 32                                                   Polygamy
## 33                                              Good genetics
## 34                                          A little exercise
## 35                                                Pets - dogs
##    Years.gained...lost strength.of.science. strength.of.science.as.a.number
## 1               -10.00               strong                               3
## 2                -3.00           suggestive                               1
## 3                -1.50           suggestive                               1
## 4                 2.00           suggestive                               1
## 5                 3.00                 good                               2
## 6                 3.50           suggestive                               1
## 7                 7.00               strong                               3
## 8                -1.00                 good                               2
## 9               -11.00                 good                               2
## 10               -2.50           suggestive                               1
## 11              -25.00               strong                               3
## 12               -8.50               strong                               3
## 13                0.14                 good                               2
## 14                2.00               strong                               3
## 15               10.00                 good                               2
## 16               11.67           suggestive                               1
## 17               12.00           suggestive                               1
## 18               13.00           suggestive                               1
## 19               14.00               strong                               3
## 20               15.00           suggestive                               1
## 21               15.00           suggestive                               1
## 22                2.00               strong                               3
## 23                2.00           suggestive                               1
## 24                2.50           suggestive                               1
## 25                4.00           suggestive                               1
## 26                5.00           suggestive                               1
## 27                7.50                 good                               2
## 28                5.10                 good                               2
## 29                5.30           suggestive                               1
## 30                7.00           suggestive                               1
## 31                8.00           suggestive                               1
## 32                9.30           suggestive                               1
## 33                5.00               strong                               3
## 34                2.00               strong                               3
## 35                3.00               strong                               3
##                   sexes.affected   effect
## 1                           Both negative
## 2                           Both negative
## 3                           Both negative
## 4                         Female positive
## 5                           Both positive
## 6                           Male positive
## 7                           Both positive
## 8                           Both positive
## 9                           Both positive
## 10                          Both positive
## 11                          Both positive
## 12                          Both negative
## 13                          Both positive
## 14        Both, but esp. for men positive
## 15                          Both positive
## 16                          Both positive
## 17                          Both positive
## 18                          Both positive
## 19                          Both positive
## 20                          male positive
## 21                          Both positive
## 22                          Both positive
## 23                          Male positive
## 24                          Both positive
## 25                          Male positive
## 26                          Male positive
## 27                          Both positive
## 28                        Female positive
## 29                          Both positive
## 30 Both but especially for women positive
## 31                          Both positive
## 32                          Male positive
## 33                          Both positive
## 34                          Both positive
## 35                          Both positive
##                                                                                                                                                                      Comment
## 1  10 years gained (against those who continue to smoke) if you quit smoking between the ages of 25 and 24; 5 years gained if you quit smoking between the ages of 45 and 59
## 2                                                                                                                                               for 8-11 hours sitting a day
## 3                                                                                                                                  7 hours ideal, no more than 8 hrs a night
## 4                                                                                              & faith in fellow humans. calc takes average % of optimism / lack of cynicism
## 5                                                                                                 particularly for elderly. calc assumes that heart attack would cause death
## 6                                                                          higher and managerial professionals live longer from age 65+ compare to those with "routine" work
## 7                                                         Japanese / Mediterannean diet will lengthen life & reduce risks of cancer. calc applies to mediterannean diet only
## 8                                                                                                                                                                           
## 9                                                                                                                                                               a lot is bad
## 10                                                                                                                                                or living near a busy road
## 11                                                                                                                                                                    severe
## 12                                                                                                                                                                          
## 13                                                                                                                          preventative health screening in 30-49 year olds
## 14                                                                                                     compared to living at sea-level. 0.5-2.5 for women, 1.2-3.6 for men. 
## 15                                                                                                                                                                          
## 16                                                                             30% less calories increases primate and rat life. assumes humans affected same way as monkeys
## 17                                                                          as well as Yoga / Tai Chi - as relaxation exercises they all reduce health risks in older people
## 18                                                                                                                                                                          
## 19                                                                                                                                                                          
## 20                                                                                                                             in formative years of secondary / high school
## 21                                                                                                                                                                          
## 22                                                                                                           150 minutes a week of moderate-intensity, leisure time exercise
## 23                                                                                                                                                          a little is fine
## 24                                                                                                                                                as opposed to taking risks
## 25                                                                                                                                                                          
## 26                                                                                                                                                     a little wine is fine
## 27                                                                                                                                             as opposed to not having much
## 28                                                                                                                                                                          
## 29                                                                                                            & strong social relationships. based on calc (50% = 5.3 years)
## 30                                                                                           studies show it does and also doesn't, perhaps remaining active with the church
## 31                                                                                                                                    compared to living next to a busy road
## 32                                                                                                                                                                  polygamy
## 33                                                                                                      if your siblings live to 100, you will be more likely to do the same
## 34                                                                                                                                                         10 minutes a week
## 35                                                                                                                                                                          
##                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Note
## 1                                                                                                                                                                                                                                                                                                                                                                                14 if combined with exercise and eating healthy; HOWEVER those who quit smoking before they turn 35 can gain most if not all of that decade back, and even those who wait until middle age to kick the habit can add about five years back to their life expectancies.
## 2                                                                                                                                                                              No matter how much you exercise, sitting too much raises your risk of death. Regardless of whether you’re exercising for 5 hours a week, the fact that you’re sitting for the rest raises the risk of death: you can’t outrun your desk job. Compared to 4 hours per day of sitting, mortality rates for 4-8 sitting hours/day were 3.96% higher, 8-11 sitting h/d were 28% higher, 11+ sitting hours/day were 68.57% higher, regardless of the amount of exercise done.
## 3                                                                                                                                                                                                                                                                                                                                                 Averaging more than 8 hours sleep a night will increase your chances of dying within 6 years by 13-15%, than if you average 7 hours a night. 7 hours sleep = the 'safest'; but sleeping for five hours a night is less risky than eight; the average sleep time in the western world is now 6.5 hours
## 4                                                                                                                                                                                                                                                                                                                                                                 Women within the highest 25% of optimism scores had a 9% lower chance of developing heart disease and a 14% lower chance of dying of any cause. Women with the highest degree of cynical hostility were 16% more likely to die than those with the most trust in their fellow humans.
## 5                                                                                                                                                                                                            (1) Cats - According to a study by the Minnesota Stroke Institute that followed more than 4,000 cat owners over 10 years, owning a cat can dramatically reduce a person's chance of dying from heart disease [source: Mundell]. Specifically, people who owned cats were 30 percent less likely to suffer a heart attack. (2) It has also been found that pets in general can help older people and patients recovering from major illness
## 6                                                                                                                                                                                                                                                                                                                                                                                                                                                  At age 65, LE of males (2002-06) classified by occupation as “Higher managerial and professional” was 18.8 years compared with 15.3 years for those assigned to occupations classifies as “Routine” 
## 7                                                                                                      Figure given for Mediterannean diet. JAPANESE: A diet comprising one-third less than the recommended 2,300 calories and meals including fish, vegetables and soya products, was cited as the reason for a high life expectancy on the Japanese island of Okinawa, where the world’s highest number of people over 90 live. MEDITERANNEAN: In people ages 70–90, eating a Mediterranean-style diet and greater physical activity are associated with 65–73% lower rates of all-cause mortality, as well as mortality due to CHD, CVD and cancer. 
## 8                                                                                                                                                                                                                                                                                                                                                                                                                                                                   risk of dying in a given year increases by 13% if diet has a high red meat content. argues that eating burger has equivalent life-shortening effects as smoking 2 cigarettes a day.
## 9                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Alcoholism reduces life expectancy by about 10 - 12 years.
## 10                                                                                                                                                                                                                                                                                                                                                                                                                                                                            According to a Canada’s McMaster University study, just living next to a busy road could knock 2.5 years off your life due to increased exposure to traffic air pollution
## 11                                                                                                                                                                                                                                                                                                                                                                                                                                            Study found that those with severe mental illness are two to three times more likely to have chronic medical conditions and have a 25-year shorter life expectancy on average than the general population
## 12                                                                                                                                                                                                                                                                                                                                                                                                          In one study, US 18 year olds with a BMI above 35 had a life expectancy reduced by five to 12 years depending on race, sex, and whether or not the person smoked. The largest reduction in life expectancy occurred for white male smokers.
## 13                                                                                                                                                                                                                                                                                                                                                                                                                                              Preventive health screening and consultation in primary care in 30- to 49-year-olds produce significantly better life expectancy without extra direct and total costs over a six-year follow-up period.
## 14 "Lower oxygen levels turn on certain genes and we think those genes may change the way heart muscles function. They may also produce new blood vessels that create new highways for blood flow into the heart, also increased solar radiation at altitude helps the body better synthesize vitamin D which has also been shown to have beneficial effects on the heart and some kinds of cancer.." mountain village residents had lower death rates, and lower rates of death from heart disease, than their peers in the lowlands; concluded that high altitude enables the body to cope with lower levels of oxygen & made for a healthier heart. 
## 15                                                                                                                                                                                                                                                                                                                                                                                                                                                 Having a spouse can decrease your risk for dying from cancer as much as knocking ten years off your life. Single people spend longer in the hospital, and have a greater risk of dying after surgery
## 16                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      shown to increase rhesus monkey lifespans by 10-20% (4 years); the most striking extensions of life span occur when put on the diet from birth.
## 17                                                                                                                                                                                                                                                                                                                                                                                                                                             A study of 2,000 seniors found that those who did relaxation exercises daily had 87% fewer heart attacks than is normal for their age group; 55% fewer cancerous tumors; & 87% fewer nervous disorders. 
## 18                                                                                                                                                                                                                                                      - Eliminating heart disease would increase life expectancy at birth by nearly 13 years for those who would otherwise have died of heart disease.\n- Elimination of heart disease would increase life expectancy at birth by nearly 5 years for whole population i.e. a person aged 50 years would expect to live an additional 4.63 years if heart disease were eliminated as a cause of death.
## 19                                                                                                                                                                                                                                                                                                                                                                                                                    study of 20,244 men and women aged 45–79 found that 4 health behaviours (non-smoking / physically active / healthy eating / moderate alcohol intake) had an estimated impact on mortality equivalent to 14 y in chronological age
## 20                                                                                                                                                                                                                                                                                                                                        Study found significant positive relationship between a man's life expectancy and the sex ratio of the secondary school he attended (i.e. higher % of females). Found that the average white American male who was 65 in 1993 could expect to live another 15 years having spent time around women at school.
## 21                                                                                                                                                                                                                                                                                                                           gain in life expectancy at birth for those individuals who would have died of cancer = 15 years.\n\nThe gains in life expectancy due to the elimination of cancer as a cause of death are then 3.35 years at birth and 3.12 years at age 50 - this is a gain in life expectancy spread across the WHOLE population though.
## 22                                                 Researchers from the National Cancer Institute, Harvard Medical School. Another study has shown that lots of physical activity combined with frequently eating nuts, not eating meat and maintaining a stable weight can lengthen life by 1.5 - 2.5 years. In a large US study, brisk walking for 450+ min/wk) increased life expectancy by 4.5 years compared to those who did no activity. Being active—having a physical activity level at or above the WHO-recommended minimum of 150 minutes of brisk walking per week—was associated with an overall gain of life expectancy of 3.4–4.5 years.
## 23                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             gain 2 years by consuming less than 2 units of alcohol a day (roughly just under 1 pint of lager) against someone who completely abstains from drinking.
## 24                                                                                                                                                                                                                                                                                                                                                                                                                                    Traits that mark people as conscientious: thinking things through before acting, being dependable in following through on their commitments, adopting conventional norms of morality and being neat and orderly. 
## 25                                                                                                                                                                                                                                                                                                                                                                               Dr Roizen - "The typical man who has 350 orgasms a year, versus the national average of around a quarter of that, lives about four years longer." And more than those extra four years, Roizen says, the men will feel eight years younger than their contemporaries. 
## 26                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                gain 5 years by consuming less than 2 units of wine a day (half a glass, or 175ml) against those who completely abstain from drinking
## 27                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          On average, poorer people in the UK become ill and die five to ten years earlier than their more privileged counterparts, in effect 'ageing' more quickly. 
## 28                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          US, 2006 - difference between male and female life expectancy was 5.1 years
## 29                                                                                                                                                                                                                                                                                                                                                                                                                                                           people with stronger social relationships had a 50% increased likelihood of survival than those with weaker social relationships. loneliness as bad for you as smoking 15 cigarettes a day
## 30                                                                                                                                                                                                                                                                                   Research conducted partly at the University of Colorado at Boulder has found that regular churchgoers live longer than people who seldom or never attend worship services. Life expectancy beyond age 20 averages another 55.3 years, to age 75, for those who never attend church compared to another 62.9 years, age 83, for those who go more than once a week.
## 31                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               Countryside dwellers have a life expectancy of 84 years, as opposed to 76 for townies.
## 32                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           12% increase, compared to average lifespan
## 33                                                                                                                                                                                                                                                                                 Professor Louis Kunkel, who led the study team, said that it was 95% likely that so many of their siblings sharing these was not simply an accident of chance. He said: "It is clear to us that longevity has a genetic component. Frequently if there is one sibling who has lived to be 100, there will be a second or third sibling who also will live to be 100.
## 34                                                                                                                                                                                                                                                                                                                                                                                                                                          Activities like gardening, walking, or dancing in a non-vigorous, leisurely way for 10 minutes to an hour per week was associated with an 18-percent lower risk of death compared to people who did nothing
## 35                                                         Dog ownership associated with longer life, especially among heart attack and stroke survivors. Researchers reviewed patient data of over 3.8 million people taken from 10 separate studies for a composite meta-analysis study, and found dog owners experienced:\n24% reduced risk of all-cause mortality\n65% reduced risk of mortality after heart attack\n31% reduced risk of mortality due to cardiovascular-related issues.\nThe lower risk of death associated with dog ownership could be explained by an increase in physical activity and the decreased depression and loneliness.
##    ID
## 1   1
## 2   2
## 3   3
## 4   4
## 5   5
## 6   6
## 7   7
## 8   8
## 9   9
## 10 10
## 11 11
## 12 12
## 13 13
## 14 14
## 15 15
## 16 16
## 17 17
## 18 18
## 19 19
## 20 20
## 21 21
## 22 22
## 23 23
## 24 24
## 25 25
## 26 26
## 27 27
## 28 28
## 29 29
## 30 30
## 31 31
## 32 32
## 33 33
## 34 34
## 35 35
##                                                                                                                                                                                                                                        Sources
## 1                                                                       Khaw KT, et al. (2008). Combined impact of health behaviours and mortality in men and women: the EPIC Norfolk prospective population study. PLoS Medicine 5(1), 39–47.
## 2                                                                                                                                                                                         Sydney School of Public Health research paper (2012)
## 3                                                                                                                                                                                                                                New Scientist
## 4                          Source: Hilary A. Tindle, M.D., assistant professor, medicine, University of Pittsburgh; Suzanne Steinbaum, M.D., director, woman and heart disease, Lenox Hill Hospital, New York City; Aug. 10, 2009, Circulation
## 5                                                                                                                                                                            Medical News Today; National Center for Biotechnology Information
## 6                                                                                                                                                                                                             Longevity Science Advisory Panel
## 7                                                                                                Amazon (book) The Okinawa Program : How the World's Longest-Lived People Achieve Everlasting Health (2002); American Heart Association (2009)
## 8                                                                                                                                                                                                                                     BBC News
## 9                                                                                                                                                                                                                               New York Times
## 10                                                                                                                                                                               2004 study by Murray Finkelstein @ Canada McMaster University
## 11                                                                                                                                                Joseph Parks, director of psychiatric services for the Missouri Department of Mental Health.
## 12                                                                                                                                                                                                                                    NIH News
## 13                                                                                                                                                                                               National Center for Biotechnology Information
## 14                                                                                                               based on a study by University of Athens Medical School in Journal of Epidemiology and Community Health, March 2005; BBC News
## 15                                                                                                          Linda Waite, university of chicago, 'The Case for Marriage: Why Married People Are Happier, Healthier, and Better off Financially'
## 16                                                                                                                                                                                                               New Scientist; New York Times
## 17                                                                                                                                                                            Marmot M (2005) 'Social determinants of longevity and mortality'
## 18                                                                                                                                                                                                    Centres for Disease Control & Prevention
## 19                                                                      Khaw KT, et al. (2008). Combined impact of health behaviours and mortality in men and women: the EPIC Norfolk prospective population study. PLoS Medicine 5(1), 39–47.
## 20                                                                                                                                                                                                                                   Economist
## 21                                                                                                                                                                                                    Centres for Disease Control & Prevention
## 22                                                                                                                                                                                              CBS; Harvard Health Publication: Living to 100
## 23                                                                                                                                                                                                                 Guardian; Wikipedia (units)
## 24                                    Kern et al (2008) 'Do conscientious individuals live longer? A quantitative review.'; New York Times; 'Personality Predictors of Longevity: Activity, Emotional Stability, and Conscientiousness' (2008)
## 25                                                                                                                                                                                           Men's Journal; Revista Mexicana de Anestesiología
## 26                                                                                                                                                                                                                 Guardian; Wikipedia (units)
## 27 Perlman RL (2008). Socioeconomic inequalities in ageing and health. Lancet 372, S34–S39. Fries JF (1980). ; Ageing, natural death and the compression of morbidity and health in the elderly. New England Journal of Medicine 313, 407–428.
## 28                                                                                                                                                                                                    Centres for Disease Control & Prevention
## 29                                                                                                                                                                                                                     Guardian; Plos Medicine
## 30                                                                                                                                                                Science Daily; Demography (1999) 'Religious involvement and adult mortality'
## 31                                                                                                                                                                               2004 study by Murray Finkelstein @ Canada McMaster University
## 32                                                                                                                                                                                                                               New Scientist
## 33                                                                                                                                                                                                                              Havard Gazette
## 34                                                                                                                                                                                                                     British Medical Journal
## 35                                                                                                                                                                                                          Industrial Safety and Hygiene News
##                                                                                                                                                                                                Links
## 1                                                                                                                                http://www.washingtonpost.com/wp-dyn/articles/A61981-2004Jun22.html
## 2                                                                                                                                                        http://www.ncbi.nlm.nih.gov/pubmed/22450936
## 3                                                                                                                       http://www.newscientist.com/article/dn1928-seven-hours-sleep-the-safest.html
## 4                                                                                                                                              www.nlm.nih.gov/medlineplus/news/fullstory_87950.html
## 5                                                                                                                                                 http://www.medicalnewstoday.com/articles/98432.php
## 6                                                                                                                   http://www.longevitypanel.co.uk/docs/life-expectancy-by-socio-economic-group.pdf
## 7                                                                                                               http://www.amazon.com/Okinawa-Program-Longest-Lived-Everlasting-Health/dp/0609807501
## 8                                                                                                                                                        http://www.bbc.co.uk/news/magazine-17389938
## 9                                                                                                             http://health.nytimes.com/health/guides/disease/alcoholism/possible-complications.html
## 10                                                                                                                                              http://aje.oxfordjournals.org/content/160/2/173.full
## 11                    http://www.healio.com/psychiatry/journals/PsycAnn/%7B9D5D6D5E-31F4-4180-9BA8-4B71AE8D6617%7D/Mental-Health-Community-Case-Management-and-Its-Effect-on-Healthcare-Expenditures
## 12                                                                                                                                                            www.nih.gov/news/pr/mar2005/nia-16.htm
## 13                                                                                                                                                       http://www.ncbi.nlm.nih.gov/pubmed/17786799
## 14                                                                                                                                                http://www.medicalnewstoday.com/releases/21265.php
## 15                                                                                                                                              http://www.psychpage.com/family/brwaitgalligher.html
## 16                                                                                                      www.newscientist.com/article/mg20327175.600-eating-less-may-be-the-key-to-living-longer.html
## 17                                                                                                                                                               http://sagecrossroads.net/webcast26
## 18                                                                                                                                            http://www.cdc.gov/nchs/data/lifetables/life89_1_4.pdf
## 19                                                                                                                         http://www.plosmedicine.org/article/info:doi/10.1371/journal.pmed.0050012
## 20                                                                                                                       http://christakis.med.harvard.edu/pdf/media-talks/archive/ec_2010_08_11.pdf
## 21                                                                                                                                            http://www.cdc.gov/nchs/data/lifetables/life89_1_4.pdf
## 22                                                                                                           http://wtvr.com/2012/11/07/study-says-exercise-lengthens-life-even-if-youre-overweight/
## 23                                                                                                                 http://www.guardian.co.uk/society/2009/apr/30/alcohol-life-expectancy-live-longer
## 24 www.ncbi.nlm.nih.gov/pubmed/18823176?ordinalpos=1&itool=EntrezSystem2.PEntrez.Pubmed.Pubmed_ResultsPanel.Pubmed_DiscoveryPanel.Pubmed_Discovery_RA&linkpos=4&log$=relatedreviews&logdbfrom=pubmed
## 25                                                                                                             http://www.mensjournal.com/health-fitness/health/the-best-reason-to-have-sex-20121001
## 26                                                                                                                 http://www.guardian.co.uk/society/2009/apr/30/alcohol-life-expectancy-live-longer
## 27                                                                                                                                                  http://www.bmj.com/cgi/content/full/319/7215/953
## 28                                                                                                                                                   www.cdc.gov/nchs/data/nvsr/nvsr57/nvsr57_14.pdf
## 29                                                                                                     http://www.guardian.co.uk/lifeandstyle/2010/jul/27/friendship-relationships-good-health-study
## 30                                                                                                                                     http://www.sciencedaily.com/releases/1999/05/990517064323.htm
## 31                                                                                                                                              http://aje.oxfordjournals.org/content/160/2/173.full
## 32                                                                                                               http://www.newscientist.com/article/dn14564-polygamy-is-the-key-to-a-long-life.html
## 33                                                                                                                                       http://news.harvard.edu/gazette/2001/09.20/08-longlife.html
## 34                                                                                                                                https://bjsm.bmj.com/content/early/2019/02/26/bjsports-2018-099254
## 35                                                                           https://www.ishn.com/articles/111649-dog-ownership-associated-with-longer-life-especially-heart-attack-stroke-survivors

Load Libraries

library(ggplot2)
library(readr)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union

Column Names

names(data)
##  [1] "Factor"                          "Years.gained...lost"            
##  [3] "strength.of.science."            "strength.of.science.as.a.number"
##  [5] "sexes.affected"                  "effect"                         
##  [7] "Comment"                         "Note"                           
##  [9] "ID"                              "Sources"                        
## [11] "Links"

Understanding the “strength of science as a number”

The “strength of science as a number” column provides a numerical measure of the scientific evidence supporting the effect of a particular factor on lifespan. It can be interpreted as follows:

Summary

summary(data)
##     Factor          Years.gained...lost strength.of.science.
##  Length:35          Min.   :-25.000     Length:35           
##  Class :character   1st Qu.:  1.070     Class :character    
##  Mode  :character   Median :  3.500     Mode  :character    
##                     Mean   :  3.243                         
##                     3rd Qu.:  7.750                         
##                     Max.   : 15.000                         
##  strength.of.science.as.a.number sexes.affected        effect         
##  Min.   :1.000                   Length:35          Length:35         
##  1st Qu.:1.000                   Class :character   Class :character  
##  Median :1.000                   Mode  :character   Mode  :character  
##  Mean   :1.771                                                        
##  3rd Qu.:3.000                                                        
##  Max.   :3.000                                                        
##    Comment              Note                 ID         Sources         
##  Length:35          Length:35          Min.   : 1.0   Length:35         
##  Class :character   Class :character   1st Qu.: 9.5   Class :character  
##  Mode  :character   Mode  :character   Median :18.0   Mode  :character  
##                                        Mean   :18.0                     
##                                        3rd Qu.:26.5                     
##                                        Max.   :35.0                     
##     Links          
##  Length:35         
##  Class :character  
##  Mode  :character  
##                    
##                    
## 

Mean

mean_data <- data %>%
  summarise(
    YearsGainedLost = mean(Years.gained...lost, na.rm = TRUE),
    StrengthOfScience = mean(strength.of.science.as.a.number, na.rm = TRUE)
  )
mean_data
##   YearsGainedLost StrengthOfScience
## 1        3.243143          1.771429

Median

median_data <- data %>%
  summarise(
    YearsGainedLost = median(Years.gained...lost, na.rm = TRUE),
    StrengthOfScience = median(strength.of.science.as.a.number, na.rm = TRUE)
  )
median_data
##   YearsGainedLost StrengthOfScience
## 1             3.5                 1

Standard Deviation

sd_data <- data %>%
  summarise(
    YearsGainedLost = sd(Years.gained...lost, na.rm = TRUE),
    StrengthOfScience = sd(strength.of.science.as.a.number, na.rm = TRUE)
  )
sd_data
##   YearsGainedLost StrengthOfScience
## 1        8.126155         0.8773528

Range

range_data <- data %>%
  summarise(
    YearsGainedLost = paste0(min(Years.gained...lost, na.rm = TRUE), " - ", max(Years.gained...lost, na.rm = TRUE)),
    StrengthOfScience = paste0(min(strength.of.science.as.a.number, na.rm = TRUE), " - ", max(strength.of.science.as.a.number, na.rm = TRUE))
  )
range_data
##   YearsGainedLost StrengthOfScience
## 1        -25 - 15             1 - 3

Bar Plot: Top and Bottom Factors

# Filter data by strength of science
strong_factors <- data %>% filter(`strength.of.science.` == "strong")
good_factors <- data %>% filter(`strength.of.science.` == "good")
suggestive_factors <- data %>% filter(`strength.of.science.` == "suggestive")

# Function to create the plot
create_plot <- function(data, title) {
  ggplot(data, aes(x=reorder(Factor, `Years.gained...lost`), y=`Years.gained...lost`)) +
    geom_bar(stat="identity", aes(fill=`Years.gained...lost` > 0)) +
    scale_fill_manual(values = c("TRUE" = "green", "FALSE" = "red")) +
    coord_flip() +
    labs(title=title, x="Factors", y="Years Gained / Lost") +
    theme_minimal() +
    theme(axis.text.y = element_text(size = 8)) # Adjust the text size for readability
}

# Plot for strong strength of science
create_plot(strong_factors, "Factors Affecting Lifespan (Strong Evidence)")

# Plot for good strength of science
create_plot(good_factors, "Factors Affecting Lifespan (Good Evidence)")

# Plot for suggestive strength of science
create_plot(suggestive_factors, "Factors Affecting Lifespan (Suggestive Evidence)")

# Function to create the heatmap
create_heatmap <- function(data, title) {
  ggplot(data, aes(x=reorder(Factor, `Years.gained...lost`), y=1)) +
    geom_tile(aes(fill=`Years.gained...lost`)) +
    scale_fill_gradient2(low="red", high="green", mid="yellow", midpoint=0) +
    labs(title=title, x="Factors", y="") +
    theme_minimal() +
    theme(axis.text.x = element_text(angle = 45, hjust = 1), axis.ticks.y=element_blank())
}

# Heatmap for strong strength of science
create_heatmap(strong_factors, "Factors Affecting Lifespan (Strong Evidence)")

# Heatmap for good strength of science
create_heatmap(good_factors, "Factors Affecting Lifespan (Good Evidence)")

# Heatmap for suggestive strength of science
create_heatmap(suggestive_factors, "Factors Affecting Lifespan (Suggestive Evidence)")