Friday, April 26, 2013

Summary of network clustering methods, in progress


Network clustering is discussed in graph-based models in Wikipedia's entry on Clustering analysis.

  • Hierarchical clustering using distance matrix
  • Xu,Xiaowei, Yuruk, Nurcan, Feng Zhidan, Schweiger Thomas, SCAN: A structural clustering algotihm for networks
  • Min-max cut method, C. Ding, X. He, H. Zha, M. Gu, and H. Simon, “A min-max
    cut algorithm for graph partitioning and data clustering”, Proc. of ICDM 2001.
  • Normalized cut, J. Shi and J. Malik, “Normalized cuts and imagesegmentation”, IEEE Transactions on Pattern Analysis and Machine Intelligence, Vol 22, No. 8, 2000.
  • Maximization of modularity, M. E. J. Newman and M. Girvan, “Finding and evaluating
  • community structure in networks”, Phys. Rev. E 69, 026113, (2004).


    Modularity can be calculated in igraph.
  • Markov chain clustering (MCL)
Related URLs
  • http://www.sixhat.net/finding-communities-in-networks-with-r-and-igraph.html

Monday, April 22, 2013

Hughes & Gottschling 2012, vacuolar pH limits mitochondrial function and lifespan in yeast.

Reading note on Hughes & Gottschling 2012, Nature, An early age increase in vacuolar pH limits mitochondrial function and lifespan in yeast.

HG12 found normal mitochondrial fragmentation was present early in 86% of the cells at 8 divisions, and progressed to large aggregates and small fragments in 93% of cells at 17 divisions for a strain with median lifespan of 28 divisions. This indicates that mitochondrial morphological change occurs  before the dye-off phase around the media lifespan (dramatic drop of viability).

HG12 over-expressed 250 genes that can influence mitochondrial function and screen for mutants can delay the onset of mitochondrial morphological changes during aging, using the mother cell enrichment systems. HG12 also stated that vacoular pH decreases before mitochondrial dysfunction .

Over-expression of VMA1 and AVT1 extended replicative lifespan (Figure 2d, 3d).

Calorie restriction can hold down vacuolar pH and extends replicative lifespan. It looks like that CR mostly shift the survivor curves to the right, meaning influencing the intitial mortality rate.

HG12 proposed that vauolar pH regulate the level of cytoplasmic amino acid levels, and in turn regulate mitochondrial morphology (Supplementary figure 1).

Another short article by Schmidt and Kennedy in Current Biology argued for alternative explanations:  Vacuolar pH influences cytosolic pH and then acts on mitochondrial membrane potential, or go through other genes like TOR1, RTG and Gcn4 to nucleus and then on mitochondria.









Thursday, April 18, 2013

Find out all yeast genes in bioconductor package org.Sc.sgd.db


require(org.Sc.sgd.db)
x <- org.Sc.sgdALIAS
ls(x)[grep("^Y..\\d{3}", ls(x))]

#or
ls(x)[grep("^Y\\W{2}\\d{3}", ls(x))]

Wednesday, April 17, 2013

Transfer files from Snow Leopard to GitHub using afp through Mountain Lion


An easy way to transfer files from Snow Leopard to GitHub is to afp the github directory on a Mountain Lion server, and then use the GitHub-GUI.


Create, push, and pull a Github repository for reliability-aging project on a Snow Leopard laptop.

I created a repository on GitHub website, then download the ZIP template directory, and find out the https site. 
 
$ pwd/Users/hongqin/github/reliability_aging
$ git init
$ git add *R
$ git commit -m "first reliability commit"

$ git remote add origin https://github.com/hongqin/reliability_aging.git
$ git push --force origin master 


I then added a README on GitHub website. 
 
$ git pull origin master
From https://github.com/hongqin/reliability_aging
 * branch            master     -> FETCH_HEAD
Updating 3a05312..8b48895
error: The following untracked working tree files would be overwritten by merge:
 README.md
Please move or remove them before you can merge.
Aborting
ace:reliability_aging-master hongqin$ ls README.md 
README.md
 

This is confusing. "README.md" is pulled, but there is an error. 
 
$ git add perfect.repair.20130417.R
 
$ git commit -m "after pull error"
[master d7196bd] after pull error
 1 file changed, 2 insertions(+), 1 deletion(-)
 
$ git push origin master
To https://github.com/hongqin/reliability_aging.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/hongqin/reliability_aging.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
 
$ git push --force origin master
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 319 bytes, done.
Total 3 (delta 2), reused 0 (delta 0)
To https://github.com/hongqin/reliability_aging.git
 + 8b48895...d7196bd master -> master (forced update)
 
At GitHub site, the changes can be seen. 
 
 

Reading notes, Vaupel, post-Darvinian longevity, 2003

Reading note for Vaupel, J. W.: Post-Darwinian longevity. In: Life span: evolutionary, ecological, and demographic perspectives, (Eds.) J. R. Carey and S. Tuljapurkar. Population Council, New York 2003, 258-269 (Population and Development Review 29, Supplement). [ PDF ]

Tail of life span is defined as \tau = (x_max - x_0.1) / x_0.1.  Vaupel03 found that repair leads to shortening of  \tau, and this should be general finding. Vaupel03 generalizes redundancy, repair, and low variability as "reliability" (robustness in my model).  He concludes that reliable species have short tails of longevity and unreliable species have long tails of longevity. This counterintuitive claim makes sense, because repair increase system robustness and homogeneity, therefore outlier would be fewer.

Vaupel cited a pathbreaking article in the same volume by Shiro Horiuchi, Abernathy 1979, and Gavrilov and Gavrilova 2001.

An alternative measure is \tau' = (x_max - x_0.1) / x_median, but this seems to be equivalent to Coefficient of Variation = sigma / mean.


Tuesday, April 16, 2013

Aging in regular, Poisson, and power-law network: The cost of Power-law network configuration?!


# 2013 April 16
# Compare power-law, Poisson, and regular network model of aging.

rm(list=ls());

power_numbers = function( k0, kN, gamma) {
  #k0=2; kN=50; gamma=2.5
  my.k= seq(k0, kN, 1)
  my.p = my.k^(-gamma)
  my.p = my.p / (sum(my.p))
  my.Frep = round( (kN-k0+1)*my.p + 0.5)
  return( rep(k0:kN, my.Frep) )
}
powerLawLinks = power_numbers (4,100,3)

calculate.s.m = function( lifespan, bin.size=10 ){ #lifespan is simulated data
   my.data = sort( lifespan[!is.na(lifespan)] );
   my.max = max(my.data)
   my.interval.size = bin.size
   deathFreq = c(NA, NA)
   for ( i in 1:round(length(my.data) / my.interval.size))  {
     sub = my.data[ ((i-1)* my.interval.size + 1) : (i* my.interval.size) ]
     deathFreq = rbind( deathFreq, c(mean(sub, na.rm=T), my.interval.size) )
   }
   deathFreq = data.frame(deathFreq)
   deathFreq = deathFreq[-1,] #remove NA
   #deathFreq       = table( my.data )
   deathCumulative = deathFreq
   for( i in 2:length(deathFreq[,1])) {
        deathCumulative[i, 2] = deathCumulative[i-1, 2] + deathCumulative[i, 2]               
   }
   tot = length(my.data)
   s = 1 - deathCumulative[,2]/tot
   currentLive  = tot - deathCumulative[,2]       
   m =  deathFreq[,2] / currentLive;

   #list( s=s, t=unique(my.data));
   #ret = data.frame( cbind(s, m, unique(my.data)));
   ret = data.frame( cbind(s, m, deathFreq[,1]) );
   names(ret) = c("s", "m", "t");
   ret;
}

#test
lifespan = rnorm(1000, mean=100, sd=10)
ret = calculate.s.m(lifespan)

#mm modules
#nn elements in each module
simulate.age.single.population = function(mm, nn, Npop, meanMu) {
  SystemAges = numeric(Npop);#store the lifespan for all individuals
  BlockAges = numeric(mm) #buffer for temporary storage
  for( i in 1: Npop){  # i-th individual in the population 
   for( j in 1:mm) {#Block loop
    #mu.vec strores the constant failure rates of elements
    #We are not sure whether mu.vec should be inside of Nop loop
    #mu.vec = rlnorm(n[j], mean=0.005, sd=1) #Element constant mortality rates
   
    #In GG01 paper, mu.vec are the same.
    mu.vec = rep(meanMu, nn[j])
    ElementAges =  rexp(nn[j], rate=mu.vec);   
   
    #maximum of elelementAges -> BlackAges
    BlockAges[j] = round( max(ElementAges), 2 ); 
  }
  SystemAges[i] = min(BlockAges) 
 }
 return( SystemAges )
}


##################
NSims = 50
mm = 15;  # numOfBlocks in a system
Npop = 1E2; # numOfSystems (individuals), ie population size
meanMu = 2

#meanNN = 5; #mean number of elements per module
meanNN = mean(powerLawLinks)
medianNN = median(powerLawLinks)

nn = rep(meanNN,mm) ; #regular network using mean Powerlaw
CV_regular = numeric(NSims)
for ( sim in 1:NSims) {
  SystemAges = simulate.age.single.population(mm, nn, Npop, meanMu );
  CV_regular[sim] = sd(SystemAges ) / mean( SystemAges )
}
CV_regular

nn = rep(medianNN,mm) ; #regular network using median Powerlaw
CV_regular2 = numeric(NSims)
for ( sim in 1:NSims) {
  SystemAges = simulate.age.single.population(mm, nn, Npop, meanMu );
  CV_regular2[sim] = sd(SystemAges ) / mean( SystemAges )
}
CV_regular2

#powerlaw
CV_powerlaw = numeric(NSims)
for ( sim in 1:NSims) {
  SystemAges = simulate.age.single.population(mm, powerLawLinks, Npop, meanMu );
  CV_powerlaw[sim] =  sd(SystemAges ) /mean( SystemAges )
}
CV_powerlaw

#Poisson network, using powerLaw mean
nn = rpois(mm, meanNN); # Poisson network
CV_poisson = numeric(NSims)
for ( sim in 1:NSims) {
  SystemAges = simulate.age.single.population(mm, nn, Npop, meanMu );
  CV_poisson[sim] =  sd(SystemAges ) /mean( SystemAges )
}
CV_poisson

#Poisson network, using powerLaw median
nn = rpois(mm, medianNN); # Poisson network
CV_poisson2 = numeric(NSims)
for ( sim in 1:NSims) {
  SystemAges = simulate.age.single.population(mm, nn, Npop, meanMu );
  CV_poisson2[sim] =  sd(SystemAges ) /mean( SystemAges )
}
CV_poisson2

tb = cbind(CV_powerlaw, CV_regular, CV_regular2, CV_poisson, CV_poisson2)
summary(tb)


> summary(tb)
  CV_powerlaw       CV_regular      CV_regular2       CV_poisson      CV_poisson2   
 Min.   :0.3261   Min.   :0.1312   Min.   :0.1832   Min.   :0.1360   Min.   :0.1937 
 1st Qu.:0.3611   1st Qu.:0.1399   1st Qu.:0.2062   1st Qu.:0.1518   1st Qu.:0.2250 
 Median :0.3822   Median :0.1462   Median :0.2202   Median :0.1588   Median :0.2389 
 Mean   :0.3811   Mean   :0.1466   Mean   :0.2188   Mean   :0.1589   Mean   :0.2380 
 3rd Qu.:0.4013   3rd Qu.:0.1520   3rd Qu.:0.2299   3rd Qu.:0.1663   3rd Qu.:0.2480 
 Max.   :0.4490   Max.   :0.1689   Max.   :0.2537   Max.   :0.1823   Max.   :0.2962  



Because Power-law introduces more heterogeneity, lifespan CV in power-law networks is higher than CV in regular and Poisson networks. In internet, it is claimed that power-law network are more tolerant to random failures but are sensitive to attacks. My network aging model simulates the failure of the hub-nodes in all networks and is equivalent to attacks on hub nodes. So, power-law configuration actually pose a 'cost' for biological aging. Because aged individuals are not 'selected' and only youngs are 'selected', this suggests that power-law ought to provide advantage in youngs.

The current regular and Poisson network are probably not good controls for the Power-law network. I should also try to fix the total number of interactions in each network.  I should also consider error-tolerant feature, repair with cost during this investigation.
 

Monday, April 8, 2013

Install TeX Live, TeXShop on an OS X mountain lion laptop


First, install TeXLive using port.


$ sudo port install texlive 
--->  Computing dependencies for texlive
--->  Dependencies to be installed: texlive-basic texlive-bin fontconfig ghostscript autoconf help2man p5.12-locale-gettext perl5.12 gdbm perl5 automake jbig2dec lcms2 libidn libpaper libpng libtool pkgconfig xorg-libXext xorg-xextproto xorg-libXt xorg-libsm xorg-libice libzzip poppler cairo glib2 libffi libpixman lzo2 xorg-xcb-util xrender xorg-renderproto curl curl-ca-bundle openjpeg jbigkit poppler-data t1lib texlive-common xorg-libXaw xorg-libXmu xpm xorg-libXp xorg-printproto texlive-documentation-base texlive-bin-extra detex dvipng gd2 latexdiff p5.12-algorithm-diff latexmk texlive-latex pdfjam texlive-latex-recommended pgf texlive-context texlive-fonts-recommended texlive-math-extra texlive-metapost texlive-xetex texlive-generic-recommended texlive-documentation-english texlive-fontutils lcdf-typetools ps2eps psutils t1utils texlive-lang-czechslovak texlive-lang-dutch texlive-lang-english texlive-lang-french texlive-lang-german texlive-lang-italian texlive-lang-polish texlive-lang-portuguese texlive-lang-spanish texlive-luatex
--->  Fetching archive for fontconfig
--->  Attempting to fetch fontconfig-2.10.2_0.darwin_12.x86_64.tbz2 from http://packages.macports.org/fontconfig
--->  Attempting to fetch fontconfig-2.10.2_0.darwin_12.x86_64.tbz2.rmd160 from http://packages.macports.org/fontconfig
--->  Installing fontconfig @2.10.2_0
--->  Activating fontconfig @2.10.2_0
--->  Cleaning fontconfig
--->  Fetching archive for gdbm
--->  Attempting to fetch gdbm-1.10_2.darwin_12.x86_64.tbz2 from http://packages.macports.org/gdbm
--->  Attempting to fetch gdbm-1.10_2.darwin_12.x86_64.tbz2.rmd160 from http://packages.macports.org/gdbm
--->  Installing gdbm @1.10_2
--->  Activating gdbm @1.10_2
--->  Cleaning gdbm
--->  Fetching archive for perl5.12
--->  Attempting to fetch perl5.12-5.12.4_1.darwin_12.x86_64.tbz2 from http://packages.macports.org/perl5.12
... ...



Second, install the frontend TeXShop.
$ sudo port install Texshop3

--->  Fetching archive for TeXShop3
... ...

There are some link problem fo /usr/texbin/pdflatex.  So, 
$ sudo mkdir texbin
Password:
$ cd texbin/
$ sudo ln -s /opt/local//bin/pdflatex .
$ sudo ln -s /opt/local//bin/*latex* .




VCell, FRAP, load image exercise (to be finished)





Use Frap

Choose the two backgroun, use auto merge

VCell exercise note, the beginner version

Start VCell and login.

To create a new model,  choose File->New-Biomodel,



In the structure diagram menu, click "species" icon, and use the 'arrow' to add a reaction.


Click reaction, and more window will show.

Right click a parameter that I want to change, 'Kf', and a window will show.


Right click 'Application' to add a new one.
Under "Parameters and Functions", we can specify them again.

Under Simulations, click to add a new simulation.
Click the edit icon (a notepad with pencil) to edit the simulation,



Then click "Run", the green arrow.


Use Frap
Choose the two

















Sunday, April 7, 2013

Funny/bad writings that can be used for teaching writing (in progress)


https://www.timeshighereducation.co.uk/carousels/genital-mixing-actions-buffet-zones-5-classic-exam-howlers
"the [hole in the] ozone layer was caused by arseholes".
"sex has puzzled biologists ever since it was discovered by Darwin and Mendel".
"in 1945 Stalin began to build a buffet zone in Eastern Europe".
"most books were written on valium" in the Middle Ages, rather than on vellum, which historians have led us to believe.

https://www.timeshighereducation.co.uk/news/vicious-substances-and-nobel-savages-abound-in-this-years-exam-howlers/416947.article


From Introduction to mathematical thinking at coursera:

Sisters reunited after ten years in checkout line at Safeway.

Large hole appears in High Street. City authorities are looking into it.

Mayor says bus passengers should be belted.


Memo to News media re:Flight 370. “37.5 kHz per second” is incorrect. Hz (Hertz)=cycles/sec. So 37.5kH per second is redundant.



http://www.reuters.com/article/2014/04/05/us-malaysia-airlines-idUSBREA3308J20140405




http://microbe.net/2014/05/11/only-in-america/



http://www.tickld.com/x/20-actual-quotes-from-english-exam


http://chronicle.com/article/Why-Academics-Writing-Stinks/148989?cid=megamenu

http://online.wsj.com/articles/the-cause-of-bad-writing-1411660188




Saturday, April 6, 2013

Metric proficiency is linked to scientific literacy and attitude


The link between metric systems, scientific literacy and attitude.

The daily life in the U.S.A. is based on customary units separated from the international systems of units (metric system) that are taught in sciences. Does this partition of daily life and scientific understanding hinder the scientific literacy for the American population and impose a negative connotation on science as a whole? These are the questions that we set to investigate. We designed a survey to gauge people’s scientific literacy and acceptance of scientific findings, while taking into account confounding factors such as educational background, gender, country, and age. The survey contains 3 sets of problems: one set on proficiency of the metric system, one set on scientific literacy, and one set on attitude and acceptance toward science. The survey is administrated online and through paper.


The survey received 200 responses recently, and enabled us to analyze the link of proficiency of metric systems to scientific literacy and attitude toward science. 

First, we found the scientific literacy is significantly associated with proficiency of metric system (Figure 1), which is perhaps not a surprise because science is taught in the metric system. This correlation suggests that people that are familiar with scientific knowledge are also more proficient at metric usage.

Second, we found that attitude toward science is significantly associated with proficiency of metric usage (Figure 2). Attitude toward science is also directly associated with scientific literacy (data not sure), but this association disappears if the metric proficiency is controlled in regression (data not shown). This partial correlation suggests that metric proficiency is the causal factor for both scientific literacy and attitude (Figure 3).

Third, we found that attitude toward science is significantly associated with age, suggesting that old people tend to have better attitude toward science, even when metric proficiency is controlled (Figure 4).  Because the current survey involved many faculty, it is not clear whether this association is due to our biased samples or not.  When educational degree is controlled, age is still significantly correlated with attitude toward science, and this correlation persists when people with Ph.D. are excluded from the analysis. This might mean another bias: People participated in the online survey tend to be more inclined toward science. On-campus survey were often done by papers, and target students that are not interested in science. This bias can only be mitigated by targeting a broader population.
Figure 1. Association of Scientific Literacy with Proficiency of Metric System.


Figure 2, Attitude toward science is associated with proficiency of metric usage.  
Figure 3. Metric proficiency influence both scientific literacy and attitude.



Figure 4. Older people tend to have better attitude toward science, but this might be a sampling bias.

Lastly, we need a large data and more broad sampling scale to make this survey more meaningful.  Please help us persuade more people to take this on-line survey.

We are also interested in collaboration on this survey. For anyone interested in conducting this survey, our GoogleDoc research proposal is publically available. 

The current R code and survey data are deposit into Hong Qin's GibHub repository

Some further analysis that I want to do. If people choose 'yes' for "My religious views are more important than scientific views", would answers to the rest of the attitude questions become predictably negative on science? 

Note on 2013 Nov 15, I may use interaction and auto-correlation to address the sampling bias.

References:

Tuesday, April 2, 2013

Initial analysis of metric system, scientific literacy and attitude survey result



R version 2.15.1 (2012-06-22) -- "Roasted Marshmallows"
Copyright (C) 2012 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> #2013 April 2
> # analysis of metrics, scientific literacy and attitude survey
> # Hong Qin

> rm(list=ls())
> list.files()
[1] "analysis20130402.R"   "old"                  "out.txt"             
[4] "response20130401.csv" "Rplots.pdf"          
> tb.ori = read.csv("response20130401.csv")
> str(tb.ori)
'data.frame': 196 obs. of  24 variables:
 $ Timestamp                                                                                                                             : Factor w/ 196 levels "3/13/2013 14:58:00",..: 172 173 174 175 176 177 178 179 180 181 ...
 $ Please.indicate.your.gender                                                                                                           : Factor w/ 4 levels "","Do not wish to answer",..: 2 4 3 2 3 3 3 3 3 4 ...
 $ Please.indicate.your.age.category                                                                                                     : Factor w/ 8 levels "18-22","23-30",..: 1 1 3 8 5 6 1 4 3 3 ...
 $ What.is.the.highest.education.that.you.received.or.are.pursing.                                                                       : Factor w/ 6 levels "Bachelor Degree in Arts or equivalent",..: 2 3 3 2 3 1 3 5 6 6 ...
 $ Please.indicate.the.country.in.which.you.grew.up.                                                                                     : Factor w/ 24 levels "","Australia",..: 24 24 24 24 24 24 24 24 24 6 ...
 $ Light.is.both.a.wave.and.a.particle                                                                                                   : Factor w/ 4 levels "","I don't know.",..: 3 3 3 4 2 4 3 4 3 3 ...
 $ A.man.is.2.16.meters.tall..Is.this.person.suited.to.be.a.good.professional.basketball.player.                                         : Factor w/ 3 levels "I don't know.",..: 3 2 2 3 2 2 1 2 3 2 ...
 $ A.30.year.old.scientist.found.a.6.million.year.old.fossil..When.this.scientist.becomes.35.years.old..the.age.of.his.fossil.should.be..: Factor w/ 4 levels "","6 million and 5 years old",..: 2 2 2 4 2 4 2 4 4 2 ...
 $ X.Kilo..means                                                                                                                         : Factor w/ 5 levels "","10 x","100 x",..: 4 4 3 4 2 4 2 4 4 4 ...
 $ X145.mm...___.m                                                                                                                       : num  0.145 0.145 1.45 0.145 0.145 0.145 1.45 0.145 0.145 1.45 ...
 $ Do.you.agree.that.organic.food.should.be.DNA.free.food.                                                                               : Factor w/ 3 levels "Agree","Dis-agree",..: 3 2 2 2 2 2 1 2 2 2 ...
 $ A.person.s.pant.inseam.measures.35.centimeters.                                                                                       : Factor w/ 4 levels "","I don't know",..: 4 3 3 3 4 3 2 3 3 3 ...
 $ The.weather.forecast.shows.a.high.of.32.degrees.Celcius..what.should.you.wear.                                                        : Factor w/ 4 levels "A light jacket",..: 3 2 1 3 3 2 3 2 2 2 ...
 $ What.is.an.electron.attracted.to.                                                                                                     : Factor w/ 5 levels "","Electricity¬†",..: 3 5 5 5 2 5 5 5 5 5 ...
 $ Early.human.once.lived.with.dinosaurs.                                                                                                : Factor w/ 3 levels "FALSE","I do not know.",..: 1 1 3 1 1 1 1 1 1 1 ...
 $ Lasers.work.by.focusing.sound.waves                                                                                                   : Factor w/ 3 levels "FALSE","I do not know. ",..: 3 1 1 1 1 1 2 1 3 1 ...
 $ The.continents.have.been.moving.their.location.for.millions.of.years.and.will.continue.to.move.                                       : Factor w/ 4 levels "","FALSE","I do not know. ",..: 4 4 4 4 2 4 4 4 4 4 ...
 $ Antibiotics.kills.viruses.as.well.as.bacteria.                                                                                        : Factor w/ 3 levels "FALSE","I do not know.",..: 1 1 1 1 3 1 1 1 1 1 ...
 $ Electrons.are.smaller.than.atoms                                                                                                      : Factor w/ 4 levels "","FALSE","I do no know. ",..: 4 4 4 4 4 4 4 4 4 4 ...
 $ The.center.of.the.earth.is.very.hot.                                                                                                  : Factor w/ 3 levels "FALSE","I do not know.",..: 3 3 3 3 2 3 3 3 3 3 ...
 $ My.religious.views.are.more.important.than.scientific.views.                                                                          : Factor w/ 4 levels "","I do not know",..: 4 4 4 3 3 3 3 3 3 3 ...
 $ For.me..in.my.daily.life..it.is.not.important.to.know.about.science.                                                                  : Factor w/ 4 levels "FALSE","Maybe",..: 1 1 3 1 1 1 4 1 1 1 ...
 $ Science.and.technology.are.making.our.lives.healthier..easier.and.more.comfortable.                                                   : Factor w/ 3 levels "FALSE","Not sure",..: 3 3 3 3 3 3 3 3 3 3 ...
 $ The.benefits.of.science.are.greater.than.any.harmful.effects.it.may.have.                                                             : Factor w/ 3 levels "FALSE","Not sure",..: 3 3 1 2 2 3 1 2 3 3 ...
> tb = tb.ori
> #rename the columns for convenience 
> names(tb) = c("time","gender", "age", "degree", "country", "light", "shaq", "fossil", "kilo", "mm", 
+         "food","inseam", "weather","electronCharge","earlyHuman", 
+         "laser", "continents", "antibiotics", "electronSize","earthCenter",
+         "religiousView","dailyLife","SciOnLife", "SciEffect")

> #visual check of the renaming 
> head(tb)[1:10]
               time                gender      age
1 3/5/2013 14:34:19 Do not wish to answer    18-22
2 3/5/2013 14:47:37                  Male    18-22
3 3/5/2013 14:53:48                Female    31-40
4 3/5/2013 15:01:34 Do not wish to answer Option 5
5 3/5/2013 15:03:33                Female    51-55
6 3/5/2013 16:21:51                Female    56-60
                                    degree       country         light shaq
1 Bachelor Degree in Science or equivalent United States          TRUE  Yes
2                High School or equivalent United States          TRUE   No
3                High School or equivalent United States          TRUE   No
4 Bachelor Degree in Science or equivalent United States         Wrong  Yes
5                High School or equivalent United States I don't know.   No
6    Bachelor Degree in Arts or equivalent United States         Wrong   No
                            fossil   kilo    mm
1        6 million and 5 years old 1000 x 0.145
2        6 million and 5 years old 1000 x 0.145
3        6 million and 5 years old  100 x 1.450
4 Still about 6 million years old. 1000 x 0.145
5        6 million and 5 years old   10 x 0.145
6 Still about 6 million years old. 1000 x 0.145
> head(tb.ori)[1:10]
          Timestamp Please.indicate.your.gender
1 3/5/2013 14:34:19       Do not wish to answer
2 3/5/2013 14:47:37                        Male
3 3/5/2013 14:53:48                      Female
4 3/5/2013 15:01:34       Do not wish to answer
5 3/5/2013 15:03:33                      Female
6 3/5/2013 16:21:51                      Female
  Please.indicate.your.age.category
1                             18-22
2                             18-22
3                             31-40
4                          Option 5
5                             51-55
6                             56-60
  What.is.the.highest.education.that.you.received.or.are.pursing.
1                        Bachelor Degree in Science or equivalent
2                                       High School or equivalent
3                                       High School or equivalent
4                        Bachelor Degree in Science or equivalent
5                                       High School or equivalent
6                           Bachelor Degree in Arts or equivalent
  Please.indicate.the.country.in.which.you.grew.up.
1                                     United States
2                                     United States
3                                     United States
4                                     United States
5                                     United States
6                                     United States
  Light.is.both.a.wave.and.a.particle
1                                TRUE
2                                TRUE
3                                TRUE
4                               Wrong
5                       I don't know.
6                               Wrong
  A.man.is.2.16.meters.tall..Is.this.person.suited.to.be.a.good.professional.basketball.player.
1                                                                                           Yes
2                                                                                            No
3                                                                                            No
4                                                                                           Yes
5                                                                                            No
6                                                                                            No
  A.30.year.old.scientist.found.a.6.million.year.old.fossil..When.this.scientist.becomes.35.years.old..the.age.of.his.fossil.should.be..
1                                                                                                              6 million and 5 years old
2                                                                                                              6 million and 5 years old
3                                                                                                              6 million and 5 years old
4                                                                                                       Still about 6 million years old.
5                                                                                                              6 million and 5 years old
6                                                                                                       Still about 6 million years old.
  X.Kilo..means X145.mm...___.m
1        1000 x           0.145
2        1000 x           0.145
3         100 x           1.450
4        1000 x           0.145
5          10 x           0.145
6        1000 x           0.145
> head(tb)[10:15]
     mm         food               inseam              weather  electronCharge
1 0.145 I don't know  This person is tall        A winter coat Negative charge
2 0.145    Dis-agree This person is short A Short sleeve shirt Positive charge
3 1.450    Dis-agree This person is short       A light jacket Positive charge
4 0.145    Dis-agree This person is short        A winter coat Positive charge
5 0.145    Dis-agree  This person is tall        A winter coat    Electricity¬†
6 0.145    Dis-agree This person is short A Short sleeve shirt Positive charge
  earlyHuman
1      FALSE
2      FALSE
3       TRUE
4      FALSE
5      FALSE
6      FALSE
> head(tb.ori)[10:15]
  X145.mm...___.m Do.you.agree.that.organic.food.should.be.DNA.free.food.
1           0.145                                            I don't know
2           0.145                                               Dis-agree
3           1.450                                               Dis-agree
4           0.145                                               Dis-agree
5           0.145                                               Dis-agree
6           0.145                                               Dis-agree
  A.person.s.pant.inseam.measures.35.centimeters.
1                             This person is tall
2                            This person is short
3                            This person is short
4                            This person is short
5                             This person is tall
6                            This person is short
  The.weather.forecast.shows.a.high.of.32.degrees.Celcius..what.should.you.wear.
1                                                                  A winter coat
2                                                           A Short sleeve shirt
3                                                                 A light jacket
4                                                                  A winter coat
5                                                                  A winter coat
6                                                           A Short sleeve shirt
  What.is.an.electron.attracted.to. Early.human.once.lived.with.dinosaurs.
1                   Negative charge                                  FALSE
2                   Positive charge                                  FALSE
3                   Positive charge                                   TRUE
4                   Positive charge                                  FALSE
5                      Electricity¬†                                  FALSE
6                   Positive charge                                  FALSE
> head(tb)[16:20]
  laser continents antibiotics electronSize    earthCenter
1  TRUE       TRUE       FALSE        True¬†           TRUE
2 FALSE       TRUE       FALSE        True¬†           TRUE
3 FALSE       TRUE       FALSE        True¬†           TRUE
4 FALSE       TRUE       FALSE        True¬†           TRUE
5 FALSE      FALSE        TRUE        True¬† I do not know.
6 FALSE       TRUE       FALSE        True¬†           TRUE
> head(tb.ori)[16:20]
  Lasers.work.by.focusing.sound.waves
1                                TRUE
2                               FALSE
3                               FALSE
4                               FALSE
5                               FALSE
6                               FALSE
  The.continents.have.been.moving.their.location.for.millions.of.years.and.will.continue.to.move.
1                                                                                            TRUE
2                                                                                            TRUE
3                                                                                            TRUE
4                                                                                            TRUE
5                                                                                           FALSE
6                                                                                            TRUE
  Antibiotics.kills.viruses.as.well.as.bacteria.
1                                          FALSE
2                                          FALSE
3                                          FALSE
4                                          FALSE
5                                           TRUE
6                                          FALSE
  Electrons.are.smaller.than.atoms The.center.of.the.earth.is.very.hot.
1                            True¬†                                 TRUE
2                            True¬†                                 TRUE
3                            True¬†                                 TRUE
4                            True¬†                                 TRUE
5                            True¬†                       I do not know.
6                            True¬†                                 TRUE
> head(tb)[21:24]
  religiousView dailyLife SciOnLife SciEffect
1           Yes     FALSE      TRUE      TRUE
2           Yes     FALSE      TRUE      TRUE
3           Yes   Neutral      TRUE     FALSE
4            No     FALSE      TRUE  Not sure
5            No     FALSE      TRUE  Not sure
6            No     FALSE      TRUE      TRUE
> head(tb.ori)[21:24]
  My.religious.views.are.more.important.than.scientific.views.
1                                                          Yes
2                                                          Yes
3                                                          Yes
4                                                           No
5                                                           No
6                                                           No
  For.me..in.my.daily.life..it.is.not.important.to.know.about.science.
1                                                                FALSE
2                                                                FALSE
3                                                              Neutral
4                                                                FALSE
5                                                                FALSE
6                                                                FALSE
  Science.and.technology.are.making.our.lives.healthier..easier.and.more.comfortable.
1                                                                                TRUE
2                                                                                TRUE
3                                                                                TRUE
4                                                                                TRUE
5                                                                                TRUE
6                                                                                TRUE
  The.benefits.of.science.are.greater.than.any.harmful.effects.it.may.have.
1                                                                      TRUE
2                                                                      TRUE
3                                                                     FALSE
4                                                                  Not sure
5                                                                  Not sure
6                                                                      TRUE

> head(tb)
               time                gender      age
1 3/5/2013 14:34:19 Do not wish to answer    18-22
2 3/5/2013 14:47:37                  Male    18-22
3 3/5/2013 14:53:48                Female    31-40
4 3/5/2013 15:01:34 Do not wish to answer Option 5
5 3/5/2013 15:03:33                Female    51-55
6 3/5/2013 16:21:51                Female    56-60
                                    degree       country         light shaq
1 Bachelor Degree in Science or equivalent United States          TRUE  Yes
2                High School or equivalent United States          TRUE   No
3                High School or equivalent United States          TRUE   No
4 Bachelor Degree in Science or equivalent United States         Wrong  Yes
5                High School or equivalent United States I don't know.   No
6    Bachelor Degree in Arts or equivalent United States         Wrong   No
                            fossil   kilo    mm         food
1        6 million and 5 years old 1000 x 0.145 I don't know
2        6 million and 5 years old 1000 x 0.145    Dis-agree
3        6 million and 5 years old  100 x 1.450    Dis-agree
4 Still about 6 million years old. 1000 x 0.145    Dis-agree
5        6 million and 5 years old   10 x 0.145    Dis-agree
6 Still about 6 million years old. 1000 x 0.145    Dis-agree
                inseam              weather  electronCharge earlyHuman laser
1  This person is tall        A winter coat Negative charge      FALSE  TRUE
2 This person is short A Short sleeve shirt Positive charge      FALSE FALSE
3 This person is short       A light jacket Positive charge       TRUE FALSE
4 This person is short        A winter coat Positive charge      FALSE FALSE
5  This person is tall        A winter coat    Electricity¬†      FALSE FALSE
6 This person is short A Short sleeve shirt Positive charge      FALSE FALSE
  continents antibiotics electronSize    earthCenter religiousView dailyLife
1       TRUE       FALSE        True¬†           TRUE           Yes     FALSE
2       TRUE       FALSE        True¬†           TRUE           Yes     FALSE
3       TRUE       FALSE        True¬†           TRUE           Yes   Neutral
4       TRUE       FALSE        True¬†           TRUE            No     FALSE
5      FALSE        TRUE        True¬† I do not know.            No     FALSE
6       TRUE       FALSE        True¬†           TRUE            No     FALSE
  SciOnLife SciEffect
1      TRUE      TRUE
2      TRUE      TRUE
3      TRUE     FALSE
4      TRUE  Not sure
5      TRUE  Not sure
6      TRUE      TRUE
> table(tb$gender)

                      Do not wish to answer                Female 
                    1                     3                   107 
                 Male 
                   85 
> tb$gender[tb$gender=='']='Do not wish to answer'

> table(tb$age)

                 18-22                  23-30                  31-40 
                    75                     32                     23 
                 41-50                  51-55                  56-60 
                    18                     12                     15 
More than 60 years old               Option 5 
                    20                      1 
> tb$age[tb$age=="Option 5"] = NA
> table(tb$age, tb$gender)
                        
                            Do not wish to answer Female Male
  18-22                   0                     1     59   15
  23-30                   0                     0     20   12
  31-40                   0                     0      9   14
  41-50                   0                     0      7   11
  51-55                   0                     1      2    9
  56-60                   0                     1      4   10
  More than 60 years old  0                     0      6   14
  Option 5                0                     0      0    0

> for( i in 5:length(tb[, 1])) {
+   for( j in 5:length(tb[1, ])) {
+     if ( is.na(tb[i, j]) ) {
+       # tb[i,j] = NA #do nothing
+     } else if (tb[i,j]=='') {
+       tb[i,j] = NA
+     } 
+   }
+ }

> summary(tb)
                 time                       gender   
 3/13/2013 14:58:00:  1                        :  0  
 3/18/2013 12:21:55:  1   Do not wish to answer:  4  
 3/25/2013 15:19:50:  1   Female               :107  
 3/25/2013 15:29:20:  1   Male                 : 85  
 3/25/2013 15:29:24:  1                              
 3/25/2013 16:41:29:  1                              
 (Other)           :190                              
                     age                                          degree  
 18-22                 :75   Bachelor Degree in Arts or equivalent   :38  
 23-30                 :32   Bachelor Degree in Science or equivalent:39  
 31-40                 :23   High School or equivalent               :58  
 More than 60 years old:20   M.D. or equivalent                      : 1  
 41-50                 :18   Master Degree or equivalent             :25  
 (Other)               :27   Ph.D. or equivalent                     :35  
 NA's                  : 1                                                
           country              light                shaq    
 United States :155                :  0   I don't know.: 27  
 United Kingdom:  8   I don't know.:  9   No           : 29  
 Australia     :  3   TRUE         :151   Yes          :140  
 Canada        :  3   Wrong        : 34                      
 China         :  2   NA's         :  2                      
 (Other)       : 23                                          
 NA's          :  2                                          
                              fossil        kilo           mm           
                                 :  0         :  0   Min.   :     0.01  
 6 million and 5 years old       : 67   10 x  :  6   1st Qu.:     0.14  
 I don't know                    :  8   100 x : 13   Median :     0.14  
 Still about 6 million years old.:120   1000 x:173   Mean   :  1495.29  
 NA's                            :  1   5 x   :  1   3rd Qu.:     1.12  
                                        NA's  :  3   Max.   :145000.00  
                                                     NA's   :2          
           food                      inseam                    weather   
 Agree       : 33                       :  0   A light jacket      : 25  
 Dis-agree   :118   I don't know        : 32   A Short sleeve shirt:131  
 I don't know: 45   This person is short:127   A winter coat       : 26  
                    This person is tall : 36   I don't know        : 14  
                    NA's                :  1                             
                                                                         
                                                                         
         electronCharge          earlyHuman              laser    
                :  0    FALSE         :153   FALSE          :134  
 Electricity¬†   :  5    I do not know.: 16   I do not know. : 37  
 Negative charge: 29    TRUE          : 27   TRUE           : 25  
 Neutron        : 22                                              
 Positive charge:139                                              
 NA's           :  1                                              
                                                                  
           continents          antibiotics          electronSize
                :  0   FALSE         :133                 :  0  
 FALSE          :  4   I do not know.: 11   FALSE         : 33  
 I do not know. :  7   TRUE          : 52   I do no know. : 14  
 TRUE           :184                        True¬†         :148  
 NA's           :  1                        NA's          :  1  
                                                                
                                                                
         earthCenter        religiousView   dailyLife      SciOnLife  
 FALSE         :  6                :  0   FALSE  :138   FALSE   :  8  
 I do not know.:  9   I do not know: 15   Maybe  : 12   Not sure: 18  
 TRUE          :181   No           :111   Neutral: 25   TRUE    :170  
                      Yes          : 68   TRUE   : 21                 
                      NA's         :  2                               
                                                                      
                                                                      
    SciEffect  
 FALSE   : 31  
 Not sure: 56  
 TRUE    :109  
               
               
               
               

> table(tb$weather)

      A light jacket A Short sleeve shirt        A winter coat 
                  25                  131                   26 
        I don't know 
                  14 
> tbGenWeather = table(tb$gender, tb$weather)
> tbGenWeather
                       
                        A light jacket A Short sleeve shirt A winter coat
                                     0                    0             0
  Do not wish to answer              1                    1             2
  Female                            21                   59            17
  Male                               3                   71             7
                       
                        I don't know
                                   0
  Do not wish to answer            0
  Female                          10
  Male                             4
> fisher.test( tbGenWeather)

Fisher's Exact Test for Count Data

data:  tbGenWeather 
p-value = 9.176e-05
alternative hypothesis: two.sided 


> head(tb)
               time                gender   age
1 3/5/2013 14:34:19 Do not wish to answer 18-22
2 3/5/2013 14:47:37                  Male 18-22
3 3/5/2013 14:53:48                Female 31-40
4 3/5/2013 15:01:34 Do not wish to answer  <NA>
5 3/5/2013 15:03:33                Female 51-55
6 3/5/2013 16:21:51                Female 56-60
                                    degree       country         light shaq
1 Bachelor Degree in Science or equivalent United States          TRUE  Yes
2                High School or equivalent United States          TRUE   No
3                High School or equivalent United States          TRUE   No
4 Bachelor Degree in Science or equivalent United States         Wrong  Yes
5                High School or equivalent United States I don't know.   No
6    Bachelor Degree in Arts or equivalent United States         Wrong   No
                            fossil   kilo    mm         food
1        6 million and 5 years old 1000 x 0.145 I don't know
2        6 million and 5 years old 1000 x 0.145    Dis-agree
3        6 million and 5 years old  100 x 1.450    Dis-agree
4 Still about 6 million years old. 1000 x 0.145    Dis-agree
5        6 million and 5 years old   10 x 0.145    Dis-agree
6 Still about 6 million years old. 1000 x 0.145    Dis-agree
                inseam              weather  electronCharge earlyHuman laser
1  This person is tall        A winter coat Negative charge      FALSE  TRUE
2 This person is short A Short sleeve shirt Positive charge      FALSE FALSE
3 This person is short       A light jacket Positive charge       TRUE FALSE
4 This person is short        A winter coat Positive charge      FALSE FALSE
5  This person is tall        A winter coat    Electricity¬†      FALSE FALSE
6 This person is short A Short sleeve shirt Positive charge      FALSE FALSE
  continents antibiotics electronSize    earthCenter religiousView dailyLife
1       TRUE       FALSE        True¬†           TRUE           Yes     FALSE
2       TRUE       FALSE        True¬†           TRUE           Yes     FALSE
3       TRUE       FALSE        True¬†           TRUE           Yes   Neutral
4       TRUE       FALSE        True¬†           TRUE            No     FALSE
5      FALSE        TRUE        True¬† I do not know.            No     FALSE
6       TRUE       FALSE        True¬†           TRUE            No     FALSE
  SciOnLife SciEffect
1      TRUE      TRUE
2      TRUE      TRUE
3      TRUE     FALSE
4      TRUE  Not sure
5      TRUE  Not sure
6      TRUE      TRUE
> names(tb)
 [1] "time"           "gender"         "age"            "degree"        
 [5] "country"        "light"          "shaq"           "fossil"        
 [9] "kilo"           "mm"             "food"           "inseam"        
[13] "weather"        "electronCharge" "earlyHuman"     "laser"         
[17] "continents"     "antibiotics"    "electronSize"   "earthCenter"   
[21] "religiousView"  "dailyLife"      "SciOnLife"      "SciEffect"     
> metrics = c("shaq", "kilo", "mm", "inseam", "weather")
> sciLiteracy = c("light", "fossil", "food", "electronCharge", 
+                 "earlyHuman", "laser", "continents", "antibiotics", "electronSize", "earthCenter")
> sciAttitude = c("religiousView", "dailyLife", "SciOnLife", "SciEffect")

> ##### create a second table, convert factors to numerics
> tb2 = tb[,2:5]  #this is the score table

> ###country 
> tb2$country = 0
> tb2$country[tb$country=='United States'] = 1
> table( tb2$country )

  0   1 
 41 155 
> table( tb$country )

                            Australia            Bahamas             Canada 
                 0                  3                  1                  3 
             China            Croatia             France              Ghana 
                 2                  1                  1                  1 
            Guyana              India            Jamaica              Kenya 
                 1                  1                  1                  2 
           Lebanon             Mexico             Norway             Poland 
                 1                  1                  1                  2 
Russian Federation             Rwanda            Senegal       South Africa 
                 2                  2                  1                  2 
             Syria  Trinidad & Tobago     United Kingdom      United States 
                 1                  1                  8                155 

> ########calculate the metric scores
> tb2$shaq = 0.5
> tb2$shaq[ tb$shaq=='Yes' ] = 1
> tb2$shaq[ tb$shaq=='No' ] = 0
> table(tb2$shaq)

  0 0.5   1 
 29  27 140 

> tb2$kilo = 0
> tb2$kilo[ tb$kilo=='1000 x' ] = 1
> table(tb2$kilo)

  0   1 
 23 173 

> tb2$mm=0
> tb2$mm[ tb$mm==0.145 ] = 1
> table(tb2$mm)

  0   1 
 79 117 
> table(tb$mm)

0.0145  0.145   1.45 145000 
    28    117     47      2 

> tb2$inseam = 0.5
> tb2$inseam[tb$inseam=="This person is short"] = 1
> tb2$inseam[tb$inseam=="This person is tall"] = 0
> table(tb2$inseam)

  0 0.5   1 
 36  33 127 

> tb2$weather = 0.5
> tb2$weather[tb$weather=="A Short sleeve shirt"] = 1
> tb2$weather[tb$weather=="A winter coat"] = 0
> table(tb$weather)

      A light jacket A Short sleeve shirt        A winter coat 
                  25                  131                   26 
        I don't know 
                  14 
> table(tb2$weather)

  0 0.5   1 
 26  39 131 

> #testing the grep function
> #tb$weather[ grep("shirt", tb$weather) ]

> #######calcualte the science attitude scores
> #sciAttitude = c("religiousView", "dailyLife", "SciOnLife", "SciEffect")

> tb2$religiousView = 0.5
> tb2$religiousView[grep("No", tb$religiousView)] = 1
> tb2$religiousView[grep("Yes", tb$religiousView)] = 0
> table(tb2$religiousView)

  0 0.5   1 
 68  17 111 

> tb2$dailyLife = 0.5
> tb2$dailyLife[ tb$dailyLife=='TRUE' ] = 0
> tb2$dailyLife[ tb$dailyLife=='FALSE' ] = 1
> table(tb2$dailyLife)

  0 0.5   1 
 21  37 138 

> tb2$SciOnLife = 0.5
> tb2$SciOnLife[ tb$SciOnLife=='TRUE' ] = 1
> tb2$SciOnLife[ tb$SciOnLife=='FALSE' ] = 0
> table(tb2$SciOnLife)

  0 0.5   1 
  8  18 170 

> tb2$SciEffect = 0.5
> tb2$SciEffect[ tb$SciEffect=='TRUE' ] = 1
> tb2$SciEffect[ tb$SciEffect=='FALSE' ] = 0
> table( tb2$SciEffect )

  0 0.5   1 
 31  56 109 

> ###########calculate scientific literacy
> #sciLiteracy = c("light", "fossil", "food", "electronCharge", 
> #                "earlyHuman", "laser", "continents", "antibiotics", "electronSize", "earthCenter")
> tb2$light = 0.5
> tb2$light[ tb$light=='TRUE' ] =1
> tb2$light[ tb$light=='Wrong' ] =0
> table(tb$light)

              I don't know.          TRUE         Wrong 
            0             9           151            34 
> table(tb2$light)

  0 0.5   1 
 34  11 151 

> tb2$fossil = 0.5
> tb2$fossil[ tb$fossil=='6 million and 5 years old' ] = 0
> tb2$fossil[grep('Still', tb$fossil)] = 1;
> table(tb$fossil)

                                        6 million and 5 years old 
                               0                               67 
                    I don't know Still about 6 million years old. 
                               8                              120 
> table(tb2$fossil)

  0 0.5   1 
 67   9 120 

> tb2$food = 0.5
> tb2$food[ tb$food=='Dis-agree' ] = 1
> tb2$food[grep('Agree', tb$food)] = 0; 
> table(tb$food)

       Agree    Dis-agree I don't know 
          33          118           45 
> table(tb2$food)

  0 0.5   1 
 33  45 118 

> tb2$electronCharge = 0
> tb2$electronCharge[grep('Positive', tb$electronCharge)] = 1; 
> table(tb$electronCharge)

                   Electricity¬† Negative charge         Neutron Positive charge 
              0               5              29              22             139 
> table(tb2$electronCharge)

  0   1 
 57 139 

> tb2$earlyHuman = 0.5
> tb2$earlyHuman[grep('TRUE', tb$earlyHuman)] = 0; 
> tb2$earlyHuman[grep('FALSE', tb$earlyHuman)] = 1; 
> table(tb$earlyHuman)

         FALSE I do not know.           TRUE 
           153             16             27 
> table(tb2$earlyHuman)

  0 0.5   1 
 27  16 153 

> tb2$earlyHuman = 0.5
> tb2$earlyHuman[grep('TRUE', tb$earlyHuman)] = 0; 
> tb2$earlyHuman[grep('FALSE', tb$earlyHuman)] = 1; 
> table(tb$earlyHuman)

         FALSE I do not know.           TRUE 
           153             16             27 
> table(tb2$earlyHuman)

  0 0.5   1 
 27  16 153 

> tb2$laser = 0.5
> tb2$laser[grep('TRUE', tb$laser)] = 0; 
> tb2$laser[grep('FALSE', tb$laser)] = 1; 
> table(tb$laser)

          FALSE I do not know.             TRUE 
            134              37              25 
> table(tb2$laser)

  0 0.5   1 
 25  37 134 

> tb2$continents = 0.5
> tb2$continents[grep('TRUE', tb$continents)] = 1; 
> tb2$continents[grep('FALSE', tb$continents)] = 0; 
> table(tb$continents)

                          FALSE I do not know.             TRUE 
              0               4               7             184 
> table(tb2$continents)

  0 0.5   1 
  4   8 184 

> tb2$antibiotics = 0.5
> tb2$antibiotics[grep('TRUE', tb$antibiotics)] = 0; 
> tb2$antibiotics[grep('FALSE', tb$antibiotics)] = 1; 
> table(tb$antibiotics)

         FALSE I do not know.           TRUE 
           133             11             52 
> table(tb2$antibiotics)

  0 0.5   1 
 52  11 133 

> tb2$electronSize = 0.5
> tb2$electronSize[grep('True', tb$electronSize)] = 1; 
> tb2$electronSize[grep('FALSE', tb$electronSize)] = 0; 
> table(tb$electronSize)

                        FALSE I do no know.           True¬† 
             0             33             14            148 
> table(tb2$electronSize)

  0 0.5   1 
 33  15 148 

> tb2$earthCenter = 0.5
> tb2$earthCenter[grep('TRUE', tb$earthCenter)] = 1; 
> tb2$earthCenter[grep('FALSE', tb$earthCenter)] = 0; 
> table(tb$earthCenter)

         FALSE I do not know.           TRUE 
             6              9            181 
> table(tb2$earthCenter)

  0 0.5   1 
  6   9 181 

> #sciLiteracy = c("light", "fossil", "food", "electronCharge", 
> #                "earlyHuman", "laser", "continents", "antibiotics", "electronSize", "earthCenter")

> tb2$SciLitScore = apply( tb2[, sciLiteracy], MARGIN=1, FUN=sum ) #by row
> hist(tb2$SciLitScore, br=20)

> #sciAttitude = c("religiousView", "dailyLife", "SciOnLife", "SciEffect")
> #Attitude total score
> tb2$SciAttitude = apply( tb2[, sciAttitude], MARGIN=1, FUN=sum)

> #metrics = c("shaq", "kilo", "mm", "inseam", "weather")
> #metric total score
> tb2$metric = apply( tb2[, metrics], MARGIN=1, FUN=sum )
> hist(tb2$metric, br=20)

> summary(tb)
                 time                       gender   
 3/13/2013 14:58:00:  1                        :  0  
 3/18/2013 12:21:55:  1   Do not wish to answer:  4  
 3/25/2013 15:19:50:  1   Female               :107  
 3/25/2013 15:29:20:  1   Male                 : 85  
 3/25/2013 15:29:24:  1                              
 3/25/2013 16:41:29:  1                              
 (Other)           :190                              
                     age                                          degree  
 18-22                 :75   Bachelor Degree in Arts or equivalent   :38  
 23-30                 :32   Bachelor Degree in Science or equivalent:39  
 31-40                 :23   High School or equivalent               :58  
 More than 60 years old:20   M.D. or equivalent                      : 1  
 41-50                 :18   Master Degree or equivalent             :25  
 (Other)               :27   Ph.D. or equivalent                     :35  
 NA's                  : 1                                                
           country              light                shaq    
 United States :155                :  0   I don't know.: 27  
 United Kingdom:  8   I don't know.:  9   No           : 29  
 Australia     :  3   TRUE         :151   Yes          :140  
 Canada        :  3   Wrong        : 34                      
 China         :  2   NA's         :  2                      
 (Other)       : 23                                          
 NA's          :  2                                          
                              fossil        kilo           mm           
                                 :  0         :  0   Min.   :     0.01  
 6 million and 5 years old       : 67   10 x  :  6   1st Qu.:     0.14  
 I don't know                    :  8   100 x : 13   Median :     0.14  
 Still about 6 million years old.:120   1000 x:173   Mean   :  1495.29  
 NA's                            :  1   5 x   :  1   3rd Qu.:     1.12  
                                        NA's  :  3   Max.   :145000.00  
                                                     NA's   :2          
           food                      inseam                    weather   
 Agree       : 33                       :  0   A light jacket      : 25  
 Dis-agree   :118   I don't know        : 32   A Short sleeve shirt:131  
 I don't know: 45   This person is short:127   A winter coat       : 26  
                    This person is tall : 36   I don't know        : 14  
                    NA's                :  1                             
                                                                         
                                                                         
         electronCharge          earlyHuman              laser    
                :  0    FALSE         :153   FALSE          :134  
 Electricity¬†   :  5    I do not know.: 16   I do not know. : 37  
 Negative charge: 29    TRUE          : 27   TRUE           : 25  
 Neutron        : 22                                              
 Positive charge:139                                              
 NA's           :  1                                              
                                                                  
           continents          antibiotics          electronSize
                :  0   FALSE         :133                 :  0  
 FALSE          :  4   I do not know.: 11   FALSE         : 33  
 I do not know. :  7   TRUE          : 52   I do no know. : 14  
 TRUE           :184                        True¬†         :148  
 NA's           :  1                        NA's          :  1  
                                                                
                                                                
         earthCenter        religiousView   dailyLife      SciOnLife  
 FALSE         :  6                :  0   FALSE  :138   FALSE   :  8  
 I do not know.:  9   I do not know: 15   Maybe  : 12   Not sure: 18  
 TRUE          :181   No           :111   Neutral: 25   TRUE    :170  
                      Yes          : 68   TRUE   : 21                 
                      NA's         :  2                               
                                                                      
                                                                      
    SciEffect  
 FALSE   : 31  
 Not sure: 56  
 TRUE    :109  
               
               
               
               
> summary(tb2)
                   gender                        age    
                      :  0   18-22                 :75  
 Do not wish to answer:  4   23-30                 :32  
 Female               :107   31-40                 :23  
 Male                 : 85   More than 60 years old:20  
                             41-50                 :18  
                             (Other)               :27  
                             NA's                  : 1  
                                      degree      country      
 Bachelor Degree in Arts or equivalent   :38   Min.   :0.0000  
 Bachelor Degree in Science or equivalent:39   1st Qu.:1.0000  
 High School or equivalent               :58   Median :1.0000  
 M.D. or equivalent                      : 1   Mean   :0.7908  
 Master Degree or equivalent             :25   3rd Qu.:1.0000  
 Ph.D. or equivalent                     :35   Max.   :1.0000  
                                                               
      shaq             kilo              mm             inseam      
 Min.   :0.0000   Min.   :0.0000   Min.   :0.0000   Min.   :0.0000  
 1st Qu.:0.5000   1st Qu.:1.0000   1st Qu.:0.0000   1st Qu.:0.5000  
 Median :1.0000   Median :1.0000   Median :1.0000   Median :1.0000  
 Mean   :0.7832   Mean   :0.8827   Mean   :0.5969   Mean   :0.7321  
 3rd Qu.:1.0000   3rd Qu.:1.0000   3rd Qu.:1.0000   3rd Qu.:1.0000  
 Max.   :1.0000   Max.   :1.0000   Max.   :1.0000   Max.   :1.0000  
                                                                    
    weather       religiousView      dailyLife        SciOnLife     
 Min.   :0.0000   Min.   :0.0000   Min.   :0.0000   Min.   :0.0000  
 1st Qu.:0.5000   1st Qu.:0.0000   1st Qu.:0.5000   1st Qu.:1.0000  
 Median :1.0000   Median :1.0000   Median :1.0000   Median :1.0000  
 Mean   :0.7679   Mean   :0.6097   Mean   :0.7985   Mean   :0.9133  
 3rd Qu.:1.0000   3rd Qu.:1.0000   3rd Qu.:1.0000   3rd Qu.:1.0000  
 Max.   :1.0000   Max.   :1.0000   Max.   :1.0000   Max.   :1.0000  
                                                                    
   SciEffect         light            fossil            food       
 Min.   :0.000   Min.   :0.0000   Min.   :0.0000   Min.   :0.0000  
 1st Qu.:0.500   1st Qu.:1.0000   1st Qu.:0.0000   1st Qu.:0.5000  
 Median :1.000   Median :1.0000   Median :1.0000   Median :1.0000  
 Mean   :0.699   Mean   :0.7985   Mean   :0.6352   Mean   :0.7168  
 3rd Qu.:1.000   3rd Qu.:1.0000   3rd Qu.:1.0000   3rd Qu.:1.0000  
 Max.   :1.000   Max.   :1.0000   Max.   :1.0000   Max.   :1.0000  
                                                                   
 electronCharge     earlyHuman         laser          continents    
 Min.   :0.0000   Min.   :0.0000   Min.   :0.0000   Min.   :0.0000  
 1st Qu.:0.0000   1st Qu.:1.0000   1st Qu.:0.5000   1st Qu.:1.0000  
 Median :1.0000   Median :1.0000   Median :1.0000   Median :1.0000  
 Mean   :0.7092   Mean   :0.8214   Mean   :0.7781   Mean   :0.9592  
 3rd Qu.:1.0000   3rd Qu.:1.0000   3rd Qu.:1.0000   3rd Qu.:1.0000  
 Max.   :1.0000   Max.   :1.0000   Max.   :1.0000   Max.   :1.0000  
                                                                    
  antibiotics      electronSize     earthCenter      SciLitScore    
 Min.   :0.0000   Min.   :0.0000   Min.   :0.0000   Min.   : 3.000  
 1st Qu.:0.0000   1st Qu.:1.0000   1st Qu.:1.0000   1st Qu.: 6.500  
 Median :1.0000   Median :1.0000   Median :1.0000   Median : 8.000  
 Mean   :0.7066   Mean   :0.7934   Mean   :0.9464   Mean   : 7.865  
 3rd Qu.:1.0000   3rd Qu.:1.0000   3rd Qu.:1.0000   3rd Qu.: 9.000  
 Max.   :1.0000   Max.   :1.0000   Max.   :1.0000   Max.   :10.000  
                                                                    
  SciAttitude       metric     
 Min.   :1.00   Min.   :1.000  
 1st Qu.:2.50   1st Qu.:3.000  
 Median :3.00   Median :4.000  
 Mean   :3.02   Mean   :3.763  
 3rd Qu.:4.00   3rd Qu.:5.000  
 Max.   :4.00   Max.   :5.000  
                               
> str(tb2); 
'data.frame': 196 obs. of  26 variables:
 $ gender        : Factor w/ 4 levels "","Do not wish to answer",..: 2 4 3 2 3 3 3 3 3 4 ...
 $ age           : Factor w/ 8 levels "18-22","23-30",..: 1 1 3 NA 5 6 1 4 3 3 ...
 $ degree        : Factor w/ 6 levels "Bachelor Degree in Arts or equivalent",..: 2 3 3 2 3 1 3 5 6 6 ...
 $ country       : num  1 1 1 1 1 1 1 1 1 0 ...
 $ shaq          : num  1 0 0 1 0 0 0.5 0 1 0 ...
 $ kilo          : num  1 1 0 1 0 1 0 1 1 1 ...
 $ mm            : num  1 1 0 1 1 1 0 1 1 0 ...
 $ inseam        : num  0 1 1 1 0 1 0.5 1 1 1 ...
 $ weather       : num  0 1 0.5 0 0 1 0 1 1 1 ...
 $ religiousView : num  0 0 0 1 1 1 1 1 1 1 ...
 $ dailyLife     : num  1 1 0.5 1 1 1 0 1 1 1 ...
 $ SciOnLife     : num  1 1 1 1 1 1 1 1 1 1 ...
 $ SciEffect     : num  1 1 0 0.5 0.5 1 0 0.5 1 1 ...
 $ light         : num  1 1 1 0 0.5 0 1 0 1 1 ...
 $ fossil        : num  0 0 0 1 0 1 0 1 1 0 ...
 $ food          : num  0.5 1 1 1 1 1 0 1 1 1 ...
 $ electronCharge: num  0 1 1 1 0 1 1 1 1 1 ...
 $ earlyHuman    : num  1 1 0 1 1 1 1 1 1 1 ...
 $ laser         : num  0 1 1 1 1 1 0.5 1 0 1 ...
 $ continents    : num  1 1 1 1 0 1 1 1 1 1 ...
 $ antibiotics   : num  1 1 1 1 0 1 1 1 1 1 ...
 $ electronSize  : num  1 1 1 1 1 1 1 1 1 1 ...
 $ earthCenter   : num  1 1 1 1 0.5 1 1 1 1 1 ...
 $ SciLitScore   : num  6.5 9 8 9 5 9 7.5 9 9 9 ...
 $ SciAttitude   : num  3 3 1.5 3.5 3.5 4 2 3.5 4 4 ...
 $ metric        : num  3 4 1.5 4 1 4 1 4 5 3 ...
> str(tb)
'data.frame': 196 obs. of  24 variables:
 $ time          : Factor w/ 196 levels "3/13/2013 14:58:00",..: 172 173 174 175 176 177 178 179 180 181 ...
 $ gender        : Factor w/ 4 levels "","Do not wish to answer",..: 2 4 3 2 3 3 3 3 3 4 ...
 $ age           : Factor w/ 8 levels "18-22","23-30",..: 1 1 3 NA 5 6 1 4 3 3 ...
 $ degree        : Factor w/ 6 levels "Bachelor Degree in Arts or equivalent",..: 2 3 3 2 3 1 3 5 6 6 ...
 $ country       : Factor w/ 24 levels "","Australia",..: 24 24 24 24 24 24 24 24 24 6 ...
 $ light         : Factor w/ 4 levels "","I don't know.",..: 3 3 3 4 2 4 3 4 3 3 ...
 $ shaq          : Factor w/ 3 levels "I don't know.",..: 3 2 2 3 2 2 1 2 3 2 ...
 $ fossil        : Factor w/ 4 levels "","6 million and 5 years old",..: 2 2 2 4 2 4 2 4 4 2 ...
 $ kilo          : Factor w/ 5 levels "","10 x","100 x",..: 4 4 3 4 2 4 2 4 4 4 ...
 $ mm            : num  0.145 0.145 1.45 0.145 0.145 0.145 1.45 0.145 0.145 1.45 ...
 $ food          : Factor w/ 3 levels "Agree","Dis-agree",..: 3 2 2 2 2 2 1 2 2 2 ...
 $ inseam        : Factor w/ 4 levels "","I don't know",..: 4 3 3 3 4 3 2 3 3 3 ...
 $ weather       : Factor w/ 4 levels "A light jacket",..: 3 2 1 3 3 2 3 2 2 2 ...
 $ electronCharge: Factor w/ 5 levels "","Electricity¬†",..: 3 5 5 5 2 5 5 5 5 5 ...
 $ earlyHuman    : Factor w/ 3 levels "FALSE","I do not know.",..: 1 1 3 1 1 1 1 1 1 1 ...
 $ laser         : Factor w/ 3 levels "FALSE","I do not know. ",..: 3 1 1 1 1 1 2 1 3 1 ...
 $ continents    : Factor w/ 4 levels "","FALSE","I do not know. ",..: 4 4 4 4 2 4 4 4 4 4 ...
 $ antibiotics   : Factor w/ 3 levels "FALSE","I do not know.",..: 1 1 1 1 3 1 1 1 1 1 ...
 $ electronSize  : Factor w/ 4 levels "","FALSE","I do no know. ",..: 4 4 4 4 4 4 4 4 4 4 ...
 $ earthCenter   : Factor w/ 3 levels "FALSE","I do not know.",..: 3 3 3 3 2 3 3 3 3 3 ...
 $ religiousView : Factor w/ 4 levels "","I do not know",..: 4 4 4 3 3 3 3 3 3 3 ...
 $ dailyLife     : Factor w/ 4 levels "FALSE","Maybe",..: 1 1 3 1 1 1 4 1 1 1 ...
 $ SciOnLife     : Factor w/ 3 levels "FALSE","Not sure",..: 3 3 3 3 3 3 3 3 3 3 ...
 $ SciEffect     : Factor w/ 3 levels "FALSE","Not sure",..: 3 3 1 2 2 3 1 2 3 3 ...

> pairs(tb2[, c("metric", "SciLitScore", "SciAttitude")])
> summary(lm(tb2$SciLitScore ~ tb2$metric )) #significant

Call:
lm(formula = tb2$SciLitScore ~ tb2$metric)

Residuals:
    Min      1Q  Median      3Q     Max 
-3.8633 -0.8633  0.1367  1.1367  3.5579 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  4.82796    0.36510  13.224  < 2e-16 ***
tb2$metric   0.80708    0.09289   8.688 1.52e-15 ***
---
Signif. codes:  0 ‚Äò***‚Äô 0.001 ‚Äò**‚Äô 0.01 ‚Äò*‚Äô 0.05 ‚Äò.‚Äô 0.1 ‚Äò ‚Äô 1 

Residual standard error: 1.477 on 194 degrees of freedom
Multiple R-squared: 0.2801, Adjusted R-squared: 0.2764 
F-statistic: 75.49 on 1 and 194 DF,  p-value: 1.524e-15 

> summary(lm(tb2$SciAttitude ~ tb2$metric )) #significant

Call:
lm(formula = tb2$SciAttitude ~ tb2$metric)

Residuals:
    Min      1Q  Median      3Q     Max 
-2.0931 -0.4802  0.1004  0.6004  1.3263 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  1.86726    0.18759   9.954  < 2e-16 ***
tb2$metric   0.30646    0.04773   6.421 1.02e-09 ***
---
Signif. codes:  0 ‚Äò***‚Äô 0.001 ‚Äò**‚Äô 0.01 ‚Äò*‚Äô 0.05 ‚Äò.‚Äô 0.1 ‚Äò ‚Äô 1 

Residual standard error: 0.7587 on 194 degrees of freedom
Multiple R-squared: 0.1753, Adjusted R-squared: 0.171 
F-statistic: 41.23 on 1 and 194 DF,  p-value: 1.018e-09 

> summary(lm(tb2$SciAttitude ~ tb2$SciLitScore + tb2$metric )) #significant

Call:
lm(formula = tb2$SciAttitude ~ tb2$SciLitScore + tb2$metric)

Residuals:
     Min       1Q   Median       3Q      Max 
-1.99696 -0.47506  0.08768  0.59403  1.35597 

Coefficients:
                Estimate Std. Error t value Pr(>|t|)    
(Intercept)      1.64149    0.25826   6.356 1.46e-09 ***
tb2$SciLitScore  0.04676    0.03683   1.270    0.206    
tb2$metric       0.26872    0.05616   4.785 3.40e-06 ***
---
Signif. codes:  0 ‚Äò***‚Äô 0.001 ‚Äò**‚Äô 0.01 ‚Äò*‚Äô 0.05 ‚Äò.‚Äô 0.1 ‚Äò ‚Äô 1 

Residual standard error: 0.7575 on 193 degrees of freedom
Multiple R-squared: 0.1821, Adjusted R-squared: 0.1736 
F-statistic: 21.49 on 2 and 193 DF,  p-value: 3.761e-09 

> ## metric -> SciAttitude and SciLitScore

> summary(lm(tb2$SciLitScore ~ tb2$metric + tb2$age + tb2$gender + tb2$country  )) #significant

Call:
lm(formula = tb2$SciLitScore ~ tb2$metric + tb2$age + tb2$gender + 
    tb2$country)

Residuals:
    Min      1Q  Median      3Q     Max 
-3.5596 -0.9806  0.1084  1.0762  2.8657 

Coefficients:
                              Estimate Std. Error t value Pr(>|t|)    
(Intercept)                     5.6267     0.9216   6.105 5.95e-09 ***
tb2$metric                      0.6897     0.1009   6.832 1.19e-10 ***
tb2$age23-30                    0.6247     0.3052   2.046  0.04213 *  
tb2$age31-40                    1.0488     0.3630   2.889  0.00433 ** 
tb2$age41-50                    0.4278     0.3944   1.085  0.27946    
tb2$age51-55                    0.7283     0.4777   1.525  0.12909    
tb2$age56-60                   -0.1232     0.4323  -0.285  0.77601    
tb2$ageMore than 60 years old   0.5206     0.3792   1.373  0.17149    
tb2$genderFemale               -1.1432     0.8633  -1.324  0.18706    
tb2$genderMale                 -0.6237     0.8623  -0.723  0.47042    
tb2$country                     0.2313     0.2686   0.861  0.39029    
---
Signif. codes:  0 ‚Äò***‚Äô 0.001 ‚Äò**‚Äô 0.01 ‚Äò*‚Äô 0.05 ‚Äò.‚Äô 0.1 ‚Äò ‚Äô 1 

Residual standard error: 1.428 on 184 degrees of freedom
  (1 observation deleted due to missingness)
Multiple R-squared: 0.3602, Adjusted R-squared: 0.3254 
F-statistic: 10.36 on 10 and 184 DF,  p-value: 8.714e-14 

> summary(lm(tb2$SciLitScore ~ tb2$metric + tb2$age + tb2$gender + tb2$country + tb2$SciAttitude  )) #significant

Call:
lm(formula = tb2$SciLitScore ~ tb2$metric + tb2$age + tb2$gender + 
    tb2$country + tb2$SciAttitude)

Residuals:
    Min      1Q  Median      3Q     Max 
-3.5702 -0.9920  0.0905  1.0577  2.8572 

Coefficients:
                              Estimate Std. Error t value Pr(>|t|)    
(Intercept)                    5.58235    0.94501   5.907 1.66e-08 ***
tb2$metric                     0.68266    0.10598   6.441 1.02e-09 ***
tb2$age23-30                   0.61666    0.30810   2.001  0.04682 *  
tb2$age31-40                   1.04196    0.36524   2.853  0.00483 ** 
tb2$age41-50                   0.42584    0.39547   1.077  0.28299    
tb2$age51-55                   0.71218    0.48430   1.471  0.14313    
tb2$age56-60                  -0.13642    0.43747  -0.312  0.75552    
tb2$ageMore than 60 years old  0.50055    0.39054   1.282  0.20157    
tb2$genderFemale              -1.16071    0.86905  -1.336  0.18333    
tb2$genderMale                -0.65142    0.87337  -0.746  0.45671    
tb2$country                    0.23106    0.26929   0.858  0.39201    
tb2$SciAttitude                0.03283    0.14661   0.224  0.82303    
---
Signif. codes:  0 ‚Äò***‚Äô 0.001 ‚Äò**‚Äô 0.01 ‚Äò*‚Äô 0.05 ‚Äò.‚Äô 0.1 ‚Äò ‚Äô 1 

Residual standard error: 1.432 on 183 degrees of freedom
  (1 observation deleted due to missingness)
Multiple R-squared: 0.3603, Adjusted R-squared: 0.3219 
F-statistic: 9.371 on 11 and 183 DF,  p-value: 2.844e-13 


> summary(lm(tb2$SciAttitude ~ tb2$metric + tb2$age + tb2$gender + tb2$country  )) #significant

Call:
lm(formula = tb2$SciAttitude ~ tb2$metric + tb2$age + tb2$gender + 
    tb2$country)

Residuals:
    Min      1Q  Median      3Q     Max 
-1.9827 -0.4279  0.1154  0.5238  1.4062 

Coefficients:
                              Estimate Std. Error t value Pr(>|t|)    
(Intercept)                   1.351907   0.464635   2.910  0.00407 ** 
tb2$metric                    0.214443   0.050894   4.213 3.93e-05 ***
tb2$age23-30                  0.243695   0.153886   1.584  0.11500    
tb2$age31-40                  0.208247   0.183022   1.138  0.25667    
tb2$age41-50                  0.058699   0.198815   0.295  0.76814    
tb2$age51-55                  0.490047   0.240836   2.035  0.04331 *  
tb2$age56-60                  0.402791   0.217971   1.848  0.06622 .  
tb2$ageMore than 60 years old 0.609465   0.191176   3.188  0.00168 ** 
tb2$genderFemale              0.532760   0.435236   1.224  0.22249    
tb2$genderMale                0.843844   0.434750   1.941  0.05379 .  
tb2$country                   0.007119   0.135413   0.053  0.95813    
---
Signif. codes:  0 ‚Äò***‚Äô 0.001 ‚Äò**‚Äô 0.01 ‚Äò*‚Äô 0.05 ‚Äò.‚Äô 0.1 ‚Äò ‚Äô 1 

Residual standard error: 0.7199 on 184 degrees of freedom
  (1 observation deleted due to missingness)
Multiple R-squared: 0.2946, Adjusted R-squared: 0.2562 
F-statistic: 7.684 on 10 and 184 DF,  p-value: 3.169e-10 


> ########test 
> testTwoFactorTb2 = function( fac1, fac2) {
+   tbTwo = table( tb2[,fac1], tb2[,fac2] )
+   print(tbTwo)
+   f = fisher.test(tbTwo)
+ }

> #metrics = c("shaq", "kilo", "mm", "inseam", "weather")
> #sciLiteracy = c("light", "fossil", "food", "electronCharge", 
> #                "earlyHuman", "laser", "continents", "antibiotics", "electronSize", "earthCenter")
> #sciAttitude = c("religiousView", "dailyLife", "SciOnLife", "SciEffect")

> f = testTwoFactorTb2( "shaq", "religiousView"); f
     
       0 0.5  1
  0   15   1 13
  0.5 11   4 12
  1   42  12 86

Fisher's Exact Test for Count Data

data:  tbTwo 
p-value = 0.09939
alternative hypothesis: two.sided 

> f = testTwoFactorTb2( "shaq", "dailyLife"); f
     
        0 0.5   1
  0     2   6  21
  0.5   3  10  14
  1    16  21 103

Fisher's Exact Test for Count Data

data:  tbTwo 
p-value = 0.1099
alternative hypothesis: two.sided 

> f = testTwoFactorTb2( "shaq", "SciOnLife"); f
     
        0 0.5   1
  0     2   0  27
  0.5   0   3  24
  1     6  15 119

Fisher's Exact Test for Count Data

data:  tbTwo 
p-value = 0.2275
alternative hypothesis: two.sided 


> f = testTwoFactorTb2( "shaq", "SciEffect"); f #significant effect!!!!
     
       0 0.5  1
  0    7   9 13
  0.5  7  12  8
  1   17  35 88

Fisher's Exact Test for Count Data

data:  tbTwo 
p-value = 0.009812
alternative hypothesis: two.sided 

> f = testTwoFactorTb2( "kilo", "SciEffect"); f #significant effect!!!
   
      0 0.5   1
  0   8   7   8
  1  23  49 101

Fisher's Exact Test for Count Data

data:  tbTwo 
p-value = 0.02352
alternative hypothesis: two.sided 

> f = testTwoFactorTb2( "mm", "SciEffect"); f #significant effect!!!
   
     0 0.5  1
  0 20  22 37
  1 11  34 72

Fisher's Exact Test for Count Data

data:  tbTwo 
p-value = 0.009951
alternative hypothesis: two.sided 

> f = testTwoFactorTb2( "inseam", "SciEffect"); f #significant effect!!!
     
       0 0.5  1
  0    9   7 20
  0.5  8  14 11
  1   14  35 78

Fisher's Exact Test for Count Data

data:  tbTwo 
p-value = 0.01253
alternative hypothesis: two.sided 

> f = testTwoFactorTb2( "weather", "SciEffect"); f #p=0.078
     
       0 0.5  1
  0    6  10 10
  0.5 10   9 20
  1   15  37 79

Fisher's Exact Test for Count Data

data:  tbTwo 
p-value = 0.07768
alternative hypothesis: two.sided 

> f = testTwoFactorTb2( "country", "SciEffect"); f #p=0.24
   
     0 0.5  1
  0  3  12 26
  1 28  44 83

Fisher's Exact Test for Count Data

data:  tbTwo 
p-value = 0.2366
alternative hypothesis: two.sided 


> summary(lm(tb2$SciEffect ~ tb2$kilo + tb2$country + tb2$gender + tb2$age + tb2$degree )) #significant kilo 

Call:
lm(formula = tb2$SciEffect ~ tb2$kilo + tb2$country + tb2$gender + 
    tb2$age + tb2$degree)

Residuals:
    Min      1Q  Median      3Q     Max 
-0.8335 -0.2211  0.1061  0.2569  0.6007 

Coefficients:
                                                    Estimate Std. Error t value
(Intercept)                                         0.549685   0.239429   2.296
tb2$kilo                                            0.202271   0.085085   2.377
tb2$country                                        -0.058298   0.069758  -0.836
tb2$genderFemale                                   -0.057088   0.222510  -0.257
tb2$genderMale                                      0.089409   0.221791   0.403
tb2$age23-30                                        0.004917   0.081407   0.060
tb2$age31-40                                        0.076479   0.099473   0.769
tb2$age41-50                                        0.058817   0.108455   0.542
tb2$age51-55                                        0.209009   0.125430   1.666
tb2$age56-60                                        0.088502   0.112724   0.785
tb2$ageMore than 60 years old                       0.124934   0.108513   1.151
tb2$degreeBachelor Degree in Science or equivalent -0.038077   0.087300  -0.436
tb2$degreeHigh School or equivalent                -0.034963   0.078640  -0.445
tb2$degreeM.D. or equivalent                        0.082156   0.381055   0.216
tb2$degreeMaster Degree or equivalent              -0.018872   0.106131  -0.178
tb2$degreePh.D. or equivalent                      -0.098217   0.095039  -1.033
                                                   Pr(>|t|)  
(Intercept)                                          0.0228 *
tb2$kilo                                             0.0185 *
tb2$country                                          0.4044  
tb2$genderFemale                                     0.7978  
tb2$genderMale                                       0.6873  
tb2$age23-30                                         0.9519  
tb2$age31-40                                         0.4430  
tb2$age41-50                                         0.5883  
tb2$age51-55                                         0.0974 .
tb2$age56-60                                         0.4334  
tb2$ageMore than 60 years old                        0.2511  
tb2$degreeBachelor Degree in Science or equivalent   0.6632  
tb2$degreeHigh School or equivalent                  0.6571  
tb2$degreeM.D. or equivalent                         0.8295  
tb2$degreeMaster Degree or equivalent                0.8591  
tb2$degreePh.D. or equivalent                        0.3028  
---
Signif. codes:  0 ‚Äò***‚Äô 0.001 ‚Äò**‚Äô 0.01 ‚Äò*‚Äô 0.05 ‚Äò.‚Äô 0.1 ‚Äò ‚Äô 1 

Residual standard error: 0.3629 on 179 degrees of freedom
  (1 observation deleted due to missingness)
Multiple R-squared: 0.1335, Adjusted R-squared: 0.06091 
F-statistic: 1.839 on 15 and 179 DF,  p-value: 0.03247 

> summary(lm(tb2$SciOnLife ~ tb2$kilo + tb2$country + tb2$gender + tb2$age + tb2$degree )) #no effect

Call:
lm(formula = tb2$SciOnLife ~ tb2$kilo + tb2$country + tb2$gender + 
    tb2$age + tb2$degree)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.95129  0.01410  0.07902  0.11129  0.20841 

Coefficients:
                                                    Estimate Std. Error t value
(Intercept)                                         1.017651   0.159053   6.398
tb2$kilo                                            0.037528   0.056522   0.664
tb2$country                                        -0.051927   0.046340  -1.121
tb2$genderFemale                                   -0.131418   0.147813  -0.889
tb2$genderMale                                     -0.114197   0.147335  -0.775
tb2$age23-30                                        0.060025   0.054079   1.110
tb2$age31-40                                       -0.015880   0.066080  -0.240
tb2$age41-50                                       -0.032831   0.072046  -0.456
tb2$age51-55                                        0.035270   0.083323   0.423
tb2$age56-60                                       -0.001425   0.074883  -0.019
tb2$ageMore than 60 years old                       0.047061   0.072085   0.653
tb2$degreeBachelor Degree in Science or equivalent  0.036818   0.057993   0.635
tb2$degreeHigh School or equivalent                 0.019434   0.052240   0.372
tb2$degreeM.D. or equivalent                        0.074898   0.253135   0.296
tb2$degreeMaster Degree or equivalent               0.064758   0.070503   0.919
tb2$degreePh.D. or equivalent                      -0.047408   0.063134  -0.751
                                                   Pr(>|t|)    
(Intercept)                                        1.33e-09 ***
tb2$kilo                                              0.508    
tb2$country                                           0.264    
tb2$genderFemale                                      0.375    
tb2$genderMale                                        0.439    
tb2$age23-30                                          0.269    
tb2$age31-40                                          0.810    
tb2$age41-50                                          0.649    
tb2$age51-55                                          0.673    
tb2$age56-60                                          0.985    
tb2$ageMore than 60 years old                         0.515    
tb2$degreeBachelor Degree in Science or equivalent    0.526    
tb2$degreeHigh School or equivalent                   0.710    
tb2$degreeM.D. or equivalent                          0.768    
tb2$degreeMaster Degree or equivalent                 0.360    
tb2$degreePh.D. or equivalent                         0.454    
---
Signif. codes:  0 ‚Äò***‚Äô 0.001 ‚Äò**‚Äô 0.01 ‚Äò*‚Äô 0.05 ‚Äò.‚Äô 0.1 ‚Äò ‚Äô 1 

Residual standard error: 0.241 on 179 degrees of freedom
  (1 observation deleted due to missingness)
Multiple R-squared: 0.05604, Adjusted R-squared: -0.02307 
F-statistic: 0.7084 on 15 and 179 DF,  p-value: 0.774 

> summary(lm(tb2$religiousView ~ tb2$kilo + tb2$country + tb2$gender + tb2$age + tb2$degree )) #age effect

Call:
lm(formula = tb2$religiousView ~ tb2$kilo + tb2$country + tb2$gender + 
    tb2$age + tb2$degree)

Residuals:
    Min      1Q  Median      3Q     Max 
-0.8435 -0.3345  0.0795  0.3265  0.7034 

Coefficients:
                                                   Estimate Std. Error t value
(Intercept)                                         0.25085    0.27787   0.903
tb2$kilo                                           -0.06561    0.09875  -0.664
tb2$country                                        -0.03791    0.08096  -0.468
tb2$genderFemale                                    0.34987    0.25823   1.355
tb2$genderMale                                      0.51980    0.25740   2.019
tb2$age23-30                                        0.06767    0.09448   0.716
tb2$age31-40                                        0.15464    0.11544   1.340
tb2$age41-50                                        0.25771    0.12587   2.047
tb2$age51-55                                        0.31666    0.14557   2.175
tb2$age56-60                                        0.47689    0.13082   3.645
tb2$ageMore than 60 years old                       0.33475    0.12593   2.658
tb2$degreeBachelor Degree in Science or equivalent -0.16877    0.10132  -1.666
tb2$degreeHigh School or equivalent                -0.20056    0.09126  -2.198
tb2$degreeM.D. or equivalent                        0.14033    0.44223   0.317
tb2$degreeMaster Degree or equivalent              -0.08137    0.12317  -0.661
tb2$degreePh.D. or equivalent                      -0.08513    0.11030  -0.772
                                                   Pr(>|t|)    
(Intercept)                                         0.36787    
tb2$kilo                                            0.50725    
tb2$country                                         0.64014    
tb2$genderFemale                                    0.17716    
tb2$genderMale                                      0.04493 *  
tb2$age23-30                                        0.47475    
tb2$age31-40                                        0.18210    
tb2$age41-50                                        0.04207 *  
tb2$age51-55                                        0.03091 *  
tb2$age56-60                                        0.00035 ***
tb2$ageMore than 60 years old                       0.00857 ** 
tb2$degreeBachelor Degree in Science or equivalent  0.09750 .  
tb2$degreeHigh School or equivalent                 0.02926 *  
tb2$degreeM.D. or equivalent                        0.75137    
tb2$degreeMaster Degree or equivalent               0.50972    
tb2$degreePh.D. or equivalent                       0.44121    
---
Signif. codes:  0 ‚Äò***‚Äô 0.001 ‚Äò**‚Äô 0.01 ‚Äò*‚Äô 0.05 ‚Äò.‚Äô 0.1 ‚Äò ‚Äô 1 

Residual standard error: 0.4211 on 179 degrees of freedom
  (1 observation deleted due to missingness)
Multiple R-squared: 0.2485, Adjusted R-squared: 0.1855 
F-statistic: 3.945 on 15 and 179 DF,  p-value: 3.962e-06 

> summary(lm(tb2$dailyLife ~ tb2$kilo + tb2$country + tb2$gender + tb2$age + tb2$degree )) #gender

Call:
lm(formula = tb2$dailyLife ~ tb2$kilo + tb2$country + tb2$gender + 
    tb2$age + tb2$degree)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.91792 -0.18296  0.09572  0.22627  0.62474 

Coefficients:
                                                    Estimate Std. Error t value
(Intercept)                                         0.062095   0.213746   0.291
tb2$kilo                                            0.041672   0.075958   0.549
tb2$country                                         0.109441   0.062275   1.757
tb2$genderFemale                                    0.498227   0.198642   2.508
tb2$genderMale                                      0.553555   0.197999   2.796
tb2$age23-30                                       -0.015271   0.072675  -0.210
tb2$age31-40                                        0.026855   0.088802   0.302
tb2$age41-50                                       -0.205710   0.096821  -2.125
tb2$age51-55                                        0.070667   0.111975   0.631
tb2$age56-60                                        0.003735   0.100632   0.037
tb2$ageMore than 60 years old                       0.068966   0.096873   0.712
tb2$degreeBachelor Degree in Science or equivalent  0.162050   0.077936   2.079
tb2$degreeHigh School or equivalent                 0.036532   0.070204   0.520
tb2$degreeM.D. or equivalent                        0.315824   0.340180   0.928
tb2$degreeMaster Degree or equivalent               0.275690   0.094746   2.910
tb2$degreePh.D. or equivalent                       0.137518   0.084844   1.621
                                                   Pr(>|t|)   
(Intercept)                                         0.77176   
tb2$kilo                                            0.58395   
tb2$country                                         0.08056 . 
tb2$genderFemale                                    0.01303 * 
tb2$genderMale                                      0.00574 **
tb2$age23-30                                        0.83381   
tb2$age31-40                                        0.76269   
tb2$age41-50                                        0.03499 * 
tb2$age51-55                                        0.52878   
tb2$age56-60                                        0.97043   
tb2$ageMore than 60 years old                       0.47744   
tb2$degreeBachelor Degree in Science or equivalent  0.03902 * 
tb2$degreeHigh School or equivalent                 0.60345   
tb2$degreeM.D. or equivalent                        0.35445   
tb2$degreeMaster Degree or equivalent               0.00408 **
tb2$degreePh.D. or equivalent                       0.10681   
---
Signif. codes:  0 ‚Äò***‚Äô 0.001 ‚Äò**‚Äô 0.01 ‚Äò*‚Äô 0.05 ‚Äò.‚Äô 0.1 ‚Äò ‚Äô 1 

Residual standard error: 0.3239 on 179 degrees of freedom
  (1 observation deleted due to missingness)
Multiple R-squared: 0.1558, Adjusted R-squared: 0.08502 
F-statistic: 2.202 on 15 and 179 DF,  p-value: 0.007798 


> summary(lm(tb2$religiousView ~ tb2$kilo + tb2$country + tb2$gender + tb2$age + tb2$degree )) #significant age, gender 

Call:
lm(formula = tb2$religiousView ~ tb2$kilo + tb2$country + tb2$gender + 
    tb2$age + tb2$degree)

Residuals:
    Min      1Q  Median      3Q     Max 
-0.8435 -0.3345  0.0795  0.3265  0.7034 

Coefficients:
                                                   Estimate Std. Error t value
(Intercept)                                         0.25085    0.27787   0.903
tb2$kilo                                           -0.06561    0.09875  -0.664
tb2$country                                        -0.03791    0.08096  -0.468
tb2$genderFemale                                    0.34987    0.25823   1.355
tb2$genderMale                                      0.51980    0.25740   2.019
tb2$age23-30                                        0.06767    0.09448   0.716
tb2$age31-40                                        0.15464    0.11544   1.340
tb2$age41-50                                        0.25771    0.12587   2.047
tb2$age51-55                                        0.31666    0.14557   2.175
tb2$age56-60                                        0.47689    0.13082   3.645
tb2$ageMore than 60 years old                       0.33475    0.12593   2.658
tb2$degreeBachelor Degree in Science or equivalent -0.16877    0.10132  -1.666
tb2$degreeHigh School or equivalent                -0.20056    0.09126  -2.198
tb2$degreeM.D. or equivalent                        0.14033    0.44223   0.317
tb2$degreeMaster Degree or equivalent              -0.08137    0.12317  -0.661
tb2$degreePh.D. or equivalent                      -0.08513    0.11030  -0.772
                                                   Pr(>|t|)    
(Intercept)                                         0.36787    
tb2$kilo                                            0.50725    
tb2$country                                         0.64014    
tb2$genderFemale                                    0.17716    
tb2$genderMale                                      0.04493 *  
tb2$age23-30                                        0.47475    
tb2$age31-40                                        0.18210    
tb2$age41-50                                        0.04207 *  
tb2$age51-55                                        0.03091 *  
tb2$age56-60                                        0.00035 ***
tb2$ageMore than 60 years old                       0.00857 ** 
tb2$degreeBachelor Degree in Science or equivalent  0.09750 .  
tb2$degreeHigh School or equivalent                 0.02926 *  
tb2$degreeM.D. or equivalent                        0.75137    
tb2$degreeMaster Degree or equivalent               0.50972    
tb2$degreePh.D. or equivalent                       0.44121    
---
Signif. codes:  0 ‚Äò***‚Äô 0.001 ‚Äò**‚Äô 0.01 ‚Äò*‚Äô 0.05 ‚Äò.‚Äô 0.1 ‚Äò ‚Äô 1 

Residual standard error: 0.4211 on 179 degrees of freedom
  (1 observation deleted due to missingness)
Multiple R-squared: 0.2485, Adjusted R-squared: 0.1855 
F-statistic: 3.945 on 15 and 179 DF,  p-value: 3.962e-06 

> summary(lm(tb2$SciOnLife ~ tb2$kilo + tb2$country + tb2$gender + tb2$age + tb2$degree )) #no effect

Call:
lm(formula = tb2$SciOnLife ~ tb2$kilo + tb2$country + tb2$gender + 
    tb2$age + tb2$degree)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.95129  0.01410  0.07902  0.11129  0.20841 

Coefficients:
                                                    Estimate Std. Error t value
(Intercept)                                         1.017651   0.159053   6.398
tb2$kilo                                            0.037528   0.056522   0.664
tb2$country                                        -0.051927   0.046340  -1.121
tb2$genderFemale                                   -0.131418   0.147813  -0.889
tb2$genderMale                                     -0.114197   0.147335  -0.775
tb2$age23-30                                        0.060025   0.054079   1.110
tb2$age31-40                                       -0.015880   0.066080  -0.240
tb2$age41-50                                       -0.032831   0.072046  -0.456
tb2$age51-55                                        0.035270   0.083323   0.423
tb2$age56-60                                       -0.001425   0.074883  -0.019
tb2$ageMore than 60 years old                       0.047061   0.072085   0.653
tb2$degreeBachelor Degree in Science or equivalent  0.036818   0.057993   0.635
tb2$degreeHigh School or equivalent                 0.019434   0.052240   0.372
tb2$degreeM.D. or equivalent                        0.074898   0.253135   0.296
tb2$degreeMaster Degree or equivalent               0.064758   0.070503   0.919
tb2$degreePh.D. or equivalent                      -0.047408   0.063134  -0.751
                                                   Pr(>|t|)    
(Intercept)                                        1.33e-09 ***
tb2$kilo                                              0.508    
tb2$country                                           0.264    
tb2$genderFemale                                      0.375    
tb2$genderMale                                        0.439    
tb2$age23-30                                          0.269    
tb2$age31-40                                          0.810    
tb2$age41-50                                          0.649    
tb2$age51-55                                          0.673    
tb2$age56-60                                          0.985    
tb2$ageMore than 60 years old                         0.515    
tb2$degreeBachelor Degree in Science or equivalent    0.526    
tb2$degreeHigh School or equivalent                   0.710    
tb2$degreeM.D. or equivalent                          0.768    
tb2$degreeMaster Degree or equivalent                 0.360    
tb2$degreePh.D. or equivalent                         0.454    
---
Signif. codes:  0 ‚Äò***‚Äô 0.001 ‚Äò**‚Äô 0.01 ‚Äò*‚Äô 0.05 ‚Äò.‚Äô 0.1 ‚Äò ‚Äô 1 

Residual standard error: 0.241 on 179 degrees of freedom
  (1 observation deleted due to missingness)
Multiple R-squared: 0.05604, Adjusted R-squared: -0.02307 
F-statistic: 0.7084 on 15 and 179 DF,  p-value: 0.774 

> summary(lm(tb2$dailyLife ~ tb2$kilo + tb2$country + tb2$gender + tb2$age + tb2$degree )) #gender effect, education

Call:
lm(formula = tb2$dailyLife ~ tb2$kilo + tb2$country + tb2$gender + 
    tb2$age + tb2$degree)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.91792 -0.18296  0.09572  0.22627  0.62474 

Coefficients:
                                                    Estimate Std. Error t value
(Intercept)                                         0.062095   0.213746   0.291
tb2$kilo                                            0.041672   0.075958   0.549
tb2$country                                         0.109441   0.062275   1.757
tb2$genderFemale                                    0.498227   0.198642   2.508
tb2$genderMale                                      0.553555   0.197999   2.796
tb2$age23-30                                       -0.015271   0.072675  -0.210
tb2$age31-40                                        0.026855   0.088802   0.302
tb2$age41-50                                       -0.205710   0.096821  -2.125
tb2$age51-55                                        0.070667   0.111975   0.631
tb2$age56-60                                        0.003735   0.100632   0.037
tb2$ageMore than 60 years old                       0.068966   0.096873   0.712
tb2$degreeBachelor Degree in Science or equivalent  0.162050   0.077936   2.079
tb2$degreeHigh School or equivalent                 0.036532   0.070204   0.520
tb2$degreeM.D. or equivalent                        0.315824   0.340180   0.928
tb2$degreeMaster Degree or equivalent               0.275690   0.094746   2.910
tb2$degreePh.D. or equivalent                       0.137518   0.084844   1.621
                                                   Pr(>|t|)   
(Intercept)                                         0.77176   
tb2$kilo                                            0.58395   
tb2$country                                         0.08056 . 
tb2$genderFemale                                    0.01303 * 
tb2$genderMale                                      0.00574 **
tb2$age23-30                                        0.83381   
tb2$age31-40                                        0.76269   
tb2$age41-50                                        0.03499 * 
tb2$age51-55                                        0.52878   
tb2$age56-60                                        0.97043   
tb2$ageMore than 60 years old                       0.47744   
tb2$degreeBachelor Degree in Science or equivalent  0.03902 * 
tb2$degreeHigh School or equivalent                 0.60345   
tb2$degreeM.D. or equivalent                        0.35445   
tb2$degreeMaster Degree or equivalent               0.00408 **
tb2$degreePh.D. or equivalent                       0.10681   
---
Signif. codes:  0 ‚Äò***‚Äô 0.001 ‚Äò**‚Äô 0.01 ‚Äò*‚Äô 0.05 ‚Äò.‚Äô 0.1 ‚Äò ‚Äô 1 

Residual standard error: 0.3239 on 179 degrees of freedom
  (1 observation deleted due to missingness)
Multiple R-squared: 0.1558, Adjusted R-squared: 0.08502 
F-statistic: 2.202 on 15 and 179 DF,  p-value: 0.007798 


> summary(lm(tb2$SciEffect ~ tb2$mm + tb2$country + tb2$gender + tb2$age + tb2$degree )) #no effect

Call:
lm(formula = tb2$SciEffect ~ tb2$mm + tb2$country + tb2$gender + 
    tb2$age + tb2$degree)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.84191 -0.22587  0.09511  0.28914  0.48110 

Coefficients:
                                                   Estimate Std. Error t value
(Intercept)                                         0.62067    0.23807   2.607
tb2$mm                                              0.10057    0.05905   1.703
tb2$country                                        -0.03996    0.07008  -0.570
tb2$genderFemale                                   -0.03053    0.22370  -0.136
tb2$genderMale                                      0.12393    0.22251   0.557
tb2$age23-30                                        0.03514    0.08286   0.424
tb2$age31-40                                        0.06967    0.10020   0.695
tb2$age41-50                                        0.04963    0.10936   0.454
tb2$age51-55                                        0.15955    0.12735   1.253
tb2$age56-60                                        0.05654    0.11439   0.494
tb2$ageMore than 60 years old                       0.11230    0.10906   1.030
tb2$degreeBachelor Degree in Science or equivalent -0.01984    0.08727  -0.227
tb2$degreeHigh School or equivalent                -0.03128    0.07922  -0.395
tb2$degreeM.D. or equivalent                        0.08516    0.38426   0.222
tb2$degreeMaster Degree or equivalent              -0.01262    0.10746  -0.117
tb2$degreePh.D. or equivalent                      -0.08974    0.09573  -0.937
                                                   Pr(>|t|)   
(Intercept)                                          0.0099 **
tb2$mm                                               0.0903 . 
tb2$country                                          0.5693   
tb2$genderFemale                                     0.8916   
tb2$genderMale                                       0.5782   
tb2$age23-30                                         0.6720   
tb2$age31-40                                         0.4878   
tb2$age41-50                                         0.6505   
tb2$age51-55                                         0.2119   
tb2$age56-60                                         0.6217   
tb2$ageMore than 60 years old                        0.3045   
tb2$degreeBachelor Degree in Science or equivalent   0.8204   
tb2$degreeHigh School or equivalent                  0.6934   
tb2$degreeM.D. or equivalent                         0.8249   
tb2$degreeMaster Degree or equivalent                0.9066   
tb2$degreePh.D. or equivalent                        0.3498   
---
Signif. codes:  0 ‚Äò***‚Äô 0.001 ‚Äò**‚Äô 0.01 ‚Äò*‚Äô 0.05 ‚Äò.‚Äô 0.1 ‚Äò ‚Äô 1 

Residual standard error: 0.3656 on 179 degrees of freedom
  (1 observation deleted due to missingness)
Multiple R-squared: 0.1204, Adjusted R-squared: 0.04671 
F-statistic: 1.634 on 15 and 179 DF,  p-value: 0.06882 

> summary(lm(tb2$SciEffect ~ tb2$inseam + tb2$country + tb2$gender + tb2$age + tb2$degree )) #random

Call:
lm(formula = tb2$SciEffect ~ tb2$inseam + tb2$country + tb2$gender + 
    tb2$age + tb2$degree)

Residuals:
    Min      1Q  Median      3Q     Max 
-0.8445 -0.2361  0.1071  0.2889  0.4879 

Coefficients:
                                                    Estimate Std. Error t value
(Intercept)                                         0.629142   0.238932   2.633
tb2$inseam                                          0.088970   0.071644   1.242
tb2$country                                        -0.046510   0.070319  -0.661
tb2$genderFemale                                   -0.050022   0.225843  -0.221
tb2$genderMale                                      0.117379   0.224368   0.523
tb2$age23-30                                        0.016829   0.082266   0.205
tb2$age31-40                                        0.048870   0.102153   0.478
tb2$age41-50                                        0.045992   0.110058   0.418
tb2$age51-55                                        0.173723   0.127244   1.365
tb2$age56-60                                        0.057793   0.115406   0.501
tb2$ageMore than 60 years old                       0.090152   0.109677   0.822
tb2$degreeBachelor Degree in Science or equivalent -0.002302   0.086559  -0.027
tb2$degreeHigh School or equivalent                -0.020527   0.079404  -0.259
tb2$degreeM.D. or equivalent                        0.115638   0.385002   0.300
tb2$degreeMaster Degree or equivalent               0.013715   0.106123   0.129
tb2$degreePh.D. or equivalent                      -0.078537   0.095617  -0.821
                                                   Pr(>|t|)   
(Intercept)                                          0.0092 **
tb2$inseam                                           0.2159   
tb2$country                                          0.5092   
tb2$genderFemale                                     0.8250   
tb2$genderMale                                       0.6015   
tb2$age23-30                                         0.8381   
tb2$age31-40                                         0.6329   
tb2$age41-50                                         0.6765   
tb2$age51-55                                         0.1739   
tb2$age56-60                                         0.6171   
tb2$ageMore than 60 years old                        0.4122   
tb2$degreeBachelor Degree in Science or equivalent   0.9788   
tb2$degreeHigh School or equivalent                  0.7963   
tb2$degreeM.D. or equivalent                         0.7643   
tb2$degreeMaster Degree or equivalent                0.8973   
tb2$degreePh.D. or equivalent                        0.4125   
---
Signif. codes:  0 ‚Äò***‚Äô 0.001 ‚Äò**‚Äô 0.01 ‚Äò*‚Äô 0.05 ‚Äò.‚Äô 0.1 ‚Äò ‚Äô 1 

Residual standard error: 0.367 on 179 degrees of freedom
  (1 observation deleted due to missingness)
Multiple R-squared: 0.1138, Adjusted R-squared: 0.03954 
F-statistic: 1.532 on 15 and 179 DF,  p-value: 0.09782 

> summary(lm(tb2$SciEffect ~ tb2$shaq + tb2$country + tb2$gender + tb2$age + tb2$degree )) #p=0.066 shaq

Call:
lm(formula = tb2$SciEffect ~ tb2$shaq + tb2$country + tb2$gender + 
    tb2$age + tb2$degree)

Residuals:
    Min      1Q  Median      3Q     Max 
-0.8601 -0.2339  0.0977  0.2691  0.5307 

Coefficients:
                                                    Estimate Std. Error t value
(Intercept)                                         0.553451   0.242835   2.279
tb2$shaq                                            0.140668   0.076161   1.847
tb2$country                                        -0.029867   0.070380  -0.424
tb2$genderFemale                                   -0.015014   0.223294  -0.067
tb2$genderMale                                      0.136150   0.221790   0.614
tb2$age23-30                                        0.004726   0.081970   0.058
tb2$age31-40                                        0.081995   0.100230   0.818
tb2$age41-50                                        0.047487   0.109246   0.435
tb2$age51-55                                        0.176785   0.126132   1.402
tb2$age56-60                                        0.091013   0.113507   0.802
tb2$ageMore than 60 years old                       0.096935   0.108758   0.891
tb2$degreeBachelor Degree in Science or equivalent -0.031329   0.088150  -0.355
tb2$degreeHigh School or equivalent                -0.039257   0.079439  -0.494
tb2$degreeM.D. or equivalent                        0.087735   0.383519   0.229
tb2$degreeMaster Degree or equivalent               0.004961   0.105772   0.047
tb2$degreePh.D. or equivalent                      -0.094381   0.095810  -0.985
                                                   Pr(>|t|)  
(Intercept)                                          0.0238 *
tb2$shaq                                             0.0664 .
tb2$country                                          0.6718  
tb2$genderFemale                                     0.9465  
tb2$genderMale                                       0.5401  
tb2$age23-30                                         0.9541  
tb2$age31-40                                         0.4144  
tb2$age41-50                                         0.6643  
tb2$age51-55                                         0.1628  
tb2$age56-60                                         0.4237  
tb2$ageMore than 60 years old                        0.3740  
tb2$degreeBachelor Degree in Science or equivalent   0.7227  
tb2$degreeHigh School or equivalent                  0.6218  
tb2$degreeM.D. or equivalent                         0.8193  
tb2$degreeMaster Degree or equivalent                0.9626  
tb2$degreePh.D. or equivalent                        0.3259  
---
Signif. codes:  0 ‚Äò***‚Äô 0.001 ‚Äò**‚Äô 0.01 ‚Äò*‚Äô 0.05 ‚Äò.‚Äô 0.1 ‚Äò ‚Äô 1 

Residual standard error: 0.3651 on 179 degrees of freedom
  (1 observation deleted due to missingness)
Multiple R-squared: 0.1229, Adjusted R-squared: 0.04938 
F-statistic: 1.672 on 15 and 179 DF,  p-value: 0.06009 

> summary(lm(tb2$SciEffect ~ tb2$weather + tb2$country + tb2$gender + tb2$age + tb2$degree )) #no effect

Call:
lm(formula = tb2$SciEffect ~ tb2$weather + tb2$country + tb2$gender + 
    tb2$age + tb2$degree)

Residuals:
    Min      1Q  Median      3Q     Max 
-0.8569 -0.2395  0.1115  0.2922  0.4976 

Coefficients:
                                                   Estimate Std. Error t value
(Intercept)                                         0.60791    0.24135   2.519
tb2$weather                                         0.09477    0.08287   1.144
tb2$country                                        -0.03086    0.07134  -0.433
tb2$genderFemale                                   -0.05128    0.22637  -0.227
tb2$genderMale                                      0.10802    0.22598   0.478
tb2$age23-30                                        0.01852    0.08238   0.225
tb2$age31-40                                        0.05866    0.10122   0.580
tb2$age41-50                                        0.05261    0.10983   0.479
tb2$age51-55                                        0.17717    0.12715   1.393
tb2$age56-60                                        0.06226    0.11513   0.541
tb2$ageMore than 60 years old                       0.09632    0.10946   0.880
tb2$degreeBachelor Degree in Science or equivalent  0.01476    0.08681   0.170
tb2$degreeHigh School or equivalent                -0.02334    0.07943  -0.294
tb2$degreeM.D. or equivalent                        0.13063    0.38512   0.339
tb2$degreeMaster Degree or equivalent               0.01237    0.10632   0.116
tb2$degreePh.D. or equivalent                      -0.07918    0.09579  -0.827
                                                   Pr(>|t|)  
(Intercept)                                          0.0127 *
tb2$weather                                          0.2543  
tb2$country                                          0.6659  
tb2$genderFemale                                     0.8211  
tb2$genderMale                                       0.6332  
tb2$age23-30                                         0.8223  
tb2$age31-40                                         0.5629  
tb2$age41-50                                         0.6325  
tb2$age51-55                                         0.1652  
tb2$age56-60                                         0.5893  
tb2$ageMore than 60 years old                        0.3801  
tb2$degreeBachelor Degree in Science or equivalent   0.8652  
tb2$degreeHigh School or equivalent                  0.7692  
tb2$degreeM.D. or equivalent                         0.7349  
tb2$degreeMaster Degree or equivalent                0.9075  
tb2$degreePh.D. or equivalent                        0.4096  
---
Signif. codes:  0 ‚Äò***‚Äô 0.001 ‚Äò**‚Äô 0.01 ‚Äò*‚Äô 0.05 ‚Äò.‚Äô 0.1 ‚Äò ‚Äô 1 

Residual standard error: 0.3672 on 179 degrees of freedom
  (1 observation deleted due to missingness)
Multiple R-squared: 0.1126, Adjusted R-squared: 0.03829 
F-statistic: 1.515 on 15 and 179 DF,  p-value: 0.1038 



> f = testTwoFactorTb2("country", "shaq")
   
      0 0.5   1
  0   2   4  35
  1  27  23 105
> f

Fisher's Exact Test for Count Data

data:  tbTwo 
p-value = 0.06516
alternative hypothesis: two.sided 


> f = testTwoFactorTb2( "country", "shaq")
   
      0 0.5   1
  0   2   4  35
  1  27  23 105
> f

Fisher's Exact Test for Count Data

data:  tbTwo 
p-value = 0.06516
alternative hypothesis: two.sided