<TeXmacs|1.0.6>

<style|generic>

<\body>
  <section|Lecture 5 - statistical tests>

  In R it is almost too easy to employ a statistical test!

  One has to be careful to understand what the test tests.

  \;

  <subsection|What is a test?>

  We have a hypothesis, and want to test if the data is consistent with this
  hypothesis. We also have an alternative hypothesis.

  Usually we will\ 

  <\enumerate-numeric>
    <item>Decide on a number to calculate from our data.

    <item>Calculate how likely is one to get this number ``or worse'' given
    our hypothesis.

    (Is ``or worse'' one- or two-sided?)

    <item>This gives us a p-value, which we compare to pre-defined cutoffs.
  </enumerate-numeric>

  The problem: how do we know how likely things are?

  We can either use distributions that the best mathematicians in the world
  figured out, or we can make our own using bootstrapping.

  <with|prog-language|r|prog-session|default|<\session>
    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      help.start()
    </input>
  </session>>

  <subsection|Loading Libraries (packages)>

  In R many functions are stored in libraries. To use them, we need to load
  the library:

  <with|prog-language|r|prog-session|default|<\session>
    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      library(stats)
    </input>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      \;
    </input>
  </session>>

  <subsection|Frequencies>

  If we observe a family with 1 male offspring, and 9 female offspring, is
  the sex ratio 50:50?

  Our hypothesis is that the sex ratio is 50%.

  Since we would have been as surprised to see 1:9 as 9:1, we want to know
  how likely is it to get a ratio of 1:9 or 9:1 or worse?

  How likely are we to get 0:10, 1:9, 9:1, or 10:0 if the ratio is really
  50%?

  The possibilities are:

  <tabular|<tformat|<table|<row|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|>>|<row|<cell|M>|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|>>|<row|<cell|F>|<cell|M>|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|>>|<row|<cell|F>|<cell|F>|<cell|M>|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|>>|<row|<cell|F>|<cell|F>|<cell|F>|<cell|M>|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|>>|<row|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|M>|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|>>|<row|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|M>|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|>>|<row|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|M>|<cell|F>|<cell|F>|<cell|F>|<cell|>>|<row|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|M>|<cell|F>|<cell|F>|<cell|>>|<row|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|M>|<cell|F>|<cell|>>|<row|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|F>|<cell|M>|<cell|>>>>>
  <tabular|<tformat|<table|<row|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|>>|<row|<cell|F>|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|>>|<row|<cell|M>|<cell|F>|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|>>|<row|<cell|M>|<cell|M>|<cell|F>|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|>>|<row|<cell|M>|<cell|M>|<cell|M>|<cell|F>|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|>>|<row|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|F>|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|>>|<row|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|F>|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|>>|<row|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|F>|<cell|M>|<cell|M>|<cell|M>|<cell|>>|<row|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|F>|<cell|M>|<cell|M>|<cell|>>|<row|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|F>|<cell|M>|<cell|>>|<row|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|M>|<cell|F>|<cell|>>>>>

  Each is equally likely. There are 1024 possibilities, 22 of which are as
  bad as our observation, so:

  <with|prog-language|r|prog-session|default|<\session>
    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      22/1024
    </input>

    <\output>
      [1] 0.02148438
    </output>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      \;
    </input>
  </session>>

  is our p-value.

  R can do this calculation thus:

  <with|prog-language|r|prog-session|default|<\session>
    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      ?binom.test
    </input>

    <\output>
      binom.test \ \ \ \ \ \ \ \ \ \ \ \ \ \ package:stats
      \ \ \ \ \ \ \ \ \ \ \ \ \ \ R Documentation

      \;

      Exact Binomial Test

      \;

      Description:

      \;

      \ \ \ \ \ Performs an exact test of a simple null hypothesis about the

      \ \ \ \ \ probability of success in a Bernoulli experiment.

      \;

      Usage:

      \;

      \ \ \ \ \ binom.test(x, n, p = 0.5,

      \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ alternative = c("two.sided", "less",
      "greater"),

      \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ conf.level = 0.95)

      \;

      Arguments:

      \;

      \ \ \ \ \ \ \ x: number of successes, or a vector of length 2 giving
      the

      \ \ \ \ \ \ \ \ \ \ numbers of successes and failures, respectively.

      \;

      \ \ \ \ \ \ \ n: number of trials; ignored if 'x' has length 2.

      \;

      \ \ \ \ \ \ \ p: hypothesized probability of success.

      \;

      alternative: indicates the alternative hypothesis and must be one of

      \ \ \ \ \ \ \ \ \ \ '"two.sided"', '"greater"' or '"less"'. You can
      specify just

      \ \ \ \ \ \ \ \ \ \ the initial letter.

      \;

      conf.level: confidence level for the returned confidence interval.

      \;

      Details:

      \;

      \ \ \ \ \ Confidence intervals are obtained by a procedure first given
      in

      \ \ \ \ \ Clopper and Pearson (1934). \ This guarantees that the
      confidence

      \ \ \ \ \ level is at least 'conf.level', but in general does not give
      the

      \ \ \ \ \ shortest-length confidence intervals.

      \;

      Value:

      \;

      \ \ \ \ \ A list with class '"htest"' containing the following
      components:\ 

      \;

      statistic: the number of successes.

      \;

      parameter: the number of trials.

      \;

      \ p.value: the p-value of the test.

      \;

      conf.int: a confidence interval for the probability of success.

      \;

      estimate: the estimated probability of success.

      \;

      null.value: the probability of success under the null, 'p'.

      \;

      alternative: a character string describing the alternative hypothesis.

      \;

      \ \ method: the character string '"Exact binomial test"'.

      \;

      data.name: a character string giving the names of the data.

      \;

      References:

      \;

      \ \ \ \ \ Clopper, C. J. & Pearson, E. S. (1934). The use of confidence
      or

      \ \ \ \ \ fiducial limits illustrated in the case of the binomial.

      \ \ \ \ \ _Biometrika_, *26*, 404-413.

      \;

      \ \ \ \ \ William J. Conover (1971), _Practical nonparametric
      statistics_.

      \ \ \ \ \ New York: John Wiley & Sons. Pages 97-104.

      \;

      \ \ \ \ \ Myles Hollander & Douglas A. Wolfe (1973), _Nonparametric

      \ \ \ \ \ statistical inference_. New York: John Wiley & Sons. Pages
      15-22.

      \;

      See Also:

      \;

      \ \ \ \ \ 'prop.test' for a general (approximate) test for equal or
      given

      \ \ \ \ \ proportions.

      \;

      Examples:

      \;

      \ \ \ \ \ ## Conover (1971), p. 97f.

      \ \ \ \ \ ## Under (the assumption of) simple Mendelian inheritance, a
      cross

      \ \ \ \ \ ## \ between plants of two particular genotypes produces
      progeny 1/4 of

      \ \ \ \ \ ## \ which are "dwarf" and 3/4 of which are "giant",
      respectively.

      \ \ \ \ \ ## \ In an experiment to determine if this assumption is
      reasonable, a

      \ \ \ \ \ ## \ cross results in progeny having 243 dwarf and 682 giant
      plants.

      \ \ \ \ \ ## \ If "giant" is taken as success, the null hypothesis is
      that p =

      \ \ \ \ \ ## \ 3/4 and the alternative that p != 3/4.

      \ \ \ \ \ binom.test(c(682, 243), p = 3/4)

      \ \ \ \ \ binom.test(682, 682 + 243, p = 3/4) \ \ # The same.

      \ \ \ \ \ ## =\<gtr\> Data are in agreement with the null hypothesis.
    </output>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      binom.test(1,10,p=0.5)
    </input>

    <\output>
      \;

      \;

      \ \ \ \ \ \ \ \ Exact binomial test

      \;

      data: \ 1 and 10\ 

      \;

      number of successes = 1, number of trials = 10, p-value = 0.02148

      alternative hypothesis: true probability of success is not equal to 0.5\ 

      95 percent confidence interval:

      \ 0.002528579 0.445016117\ 

      sample estimates:

      probability of success\ 

      \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0.1\ 
    </output>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      \;
    </input>

    \;
  </session>>

  And, we get exactly the same p-value!

  In this case, we were ``surprised'' to see so few males. But we had no
  preference for males or females. Therefore our alternative hypothesis was
  that the sex ratio is not 0.5.

  But, maybe in a previous experiment, we already saw few males. Now we just
  want to confirm that it isn't an equal sex ratio, but that we have few
  males.

  In this case we ask: what is the chance to see 1:9 or worse, i.e. 1 male, 9
  females, or 0 males 10 females?

  This is a one-sided test.

  From above we can see that the p-value in this case is 11/1024.

  <with|prog-language|r|prog-session|default|<\session>
    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      binom.test(1,10,alternative="less")
    </input>

    <\output>
      \;

      \ \ \ \ \ \ \ \ Exact binomial test

      \;

      data: \ 1 and 10\ 

      number of successes = 1, number of trials = 10, p-value = 0.01074

      alternative hypothesis: true probability of success is less than 0.5\ 

      95 percent confidence interval:

      \ 0.0000000 0.3941633\ 

      sample estimates:

      probability of success\ 

      \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0.1\ 
    </output>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      \;
    </input>
  </session>>

  If ahead of time we want to show that there are too few males, but we get 9
  males and 1 female, then we still have to test for less!

  <with|prog-language|r|prog-session|default|<\session>
    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      binom.test(9,10,alternative="less")
    </input>

    <\output>
      \;

      \ \ \ \ \ \ \ \ Exact binomial test

      \;

      data: \ 9 and 10\ 

      number of successes = 9, number of trials = 10, p-value = 0.999

      alternative hypothesis: true probability of success is less than 0.5\ 

      \;

      95 percent confidence interval:

      \ 0.0000000 0.9948838\ 

      sample estimates:

      probability of success\ 

      \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0.9\ 
    </output>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      \;
    </input>
  </session>>

  <subsection|Frequency tables>

  Let us assume that our hypothesis is that the frequency of green, blue, and
  brown eyes in the population is 20%, 30%, 50%.

  We see the following data:

  <with|prog-language|r|prog-session|default|<\session>
    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      observed=c(blue=17,blue=25,brown=60)
    </input>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      observed
    </input>

    <\output>
      \ blue \ blue brown\ 

      \ \ \ 17 \ \ \ 25 \ \ \ 60\ 
    </output>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      sum(observed)
    </input>

    <\output>
      [1] 102
    </output>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      \;
    </input>
  </session>>

  We would expect:

  <with|prog-language|r|prog-session|default|<\session>
    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      expected=c(0.2,0.3,0.5)*102
    </input>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      expected
    </input>

    <\output>
      [1] 20.4 30.6 51.0
    </output>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      \;
    </input>
  </session>>

  We could now, for example, sum the absolute difference of
  observed-expected. Or <with|mode|math|(observed-expected)<rsup|2>>.

  But for all those it will be hard to calculate to get that value.

  For the following function, we do have an approximate distribution:

  <with|mode|math|<\equation*>
    <with|mode|text|<with|mode|math|<frac|(observed value - expected
    value)<rsup|2>|expected value> >>
  </equation*>>

  <with|prog-language|r|prog-session|default|<\session>
    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      chisq.test(c(17,25,60),p=c(0.2,0.3,0.5))
    </input>

    <\output>
      \;

      \ \ \ \ \ \ \ \ Chi-squared test for given probabilities

      \;

      data: \ c(17, 25, 60)\ 

      X-squared = 3.1797, df = 2, p-value = 0.2040
    </output>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      \;
    </input>

    \;
  </session>>

  Another example:

  <with|prog-language|r|prog-session|default|<\session>
    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      hair=sample(c("blond","black"),90,rep=T,p=c(0.3,0.7))
    </input>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      eyes=sample(c("green","brown"),90,rep=T,p=c(0.8,0.2))
    </input>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      T=table(hair,eyes)
    </input>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      T
    </input>

    <\output>
      \ \ \ \ \ \ \ eyes

      hair \ \ \ brown green

      \ \ black \ \ \ \ 9 \ \ \ 53

      \ \ blond \ \ \ \ 3 \ \ \ 25
    </output>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      \;
    </input>
  </session>>

  We would like to know if hair color and eye color are independent. Our
  hypothesis is that they are independent, and therefore one can calculate
  the chance for each category from\ 

  <with|prog-language|r|prog-session|default|<\session>
    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      chisq.test(T)
    </input>

    <\output>
      \;

      \ \ \ \ \ \ \ \ Pearson's Chi-squared test with Yates' continuity
      correction

      \;

      data: \ T\ 

      X-squared = 0.0244, df = 1, p-value = 0.8758

      \;

      Warning message:

      Chi-squared approximation may be incorrect in: chisq.test(T)\ 
    </output>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      \;
    </input>

    \;
  </session>>

  The reason for the warning is that the chisq.test is only approximate. For
  small values in the table, the test is not exact. Another test is exact in
  this case:

  <with|prog-language|r|prog-session|default|<\session>
    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      fisher.test(T)
    </input>

    <\output>
      \;

      \;

      \ \ \ \ \ \ \ \ Fisher's Exact Test for Count Data

      \;

      data: \ T\ 

      \;

      p-value = 0.7472

      alternative hypothesis: true odds ratio is not equal to 1\ 

      \;

      95 percent confidence interval:

      \ 0.3149924 8.7903421\ 

      sample estimates:

      odds ratio\ 

      \ \ 1.409920\ 
    </output>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      \;
    </input>
  </session>>

  <subsection|Comparing means>

  Often we have data from two sources, and would like to know if we have the
  same means, i.e. one is not bigger than the other.

  As before, we can think of many functions one could compute.\ 

  Assuming that the data is normaly distributed, a test called t-test exists:

  The t-test calculates the (difference of the means in the two
  samples)/(std. error of mean)

  To use the t-test we have to know if the variances are the same. To do
  this, there is a test called var.test:

  <with|prog-language|r|prog-session|default|<\session>
    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      x=rnorm(20,mean=10)
    </input>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      y=rnorm(20,mean=10.5)
    </input>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      var.test(x,y)
    </input>

    <\output>
      \;

      \ \ \ \ \ \ \ \ F test to compare two variances

      \;

      data: \ x and y\ 

      \;

      F = 0.411, num df = 19, denom df = 19, p-value = 0.0597

      alternative hypothesis: true ratio of variances is not equal to 1\ 

      95 percent confidence interval:

      \ 0.1626644 1.0382793\ 

      \;

      sample estimates:

      ratio of variances\ 

      \ \ \ \ \ \ \ \ \ 0.4109636\ 
    </output>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      \;
    </input>
  </session>>

  Now we can use the t-test:

  <with|prog-language|r|prog-session|default|<\session>
    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      t.test(x,y)
    </input>

    <\output>
      \;

      \ \ \ \ \ \ \ \ Welch Two Sample t-test

      \;

      data: \ x and y\ 

      t = -0.4676, df = 32.36, p-value = 0.6432

      alternative hypothesis: true difference in means is not equal to 0\ 

      95 percent confidence interval:

      \ -0.9666928 \ 0.6055888\ 

      sample estimates:

      mean of x mean of y\ 

      \ 9.842836 10.023388\ 
    </output>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      \;
    </input>
  </session>>

  Notice that the test did not detect the difference in the variables.

  If we know or suspect that the variances are not the same, we can use a
  parameter of t.test:

  <with|prog-language|r|prog-session|default|<\session>
    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      t.test(x,y,var.eq=F)
    </input>

    <\output>
      \;

      \ \ \ \ \ \ \ \ Welch Two Sample t-test

      \;

      data: \ x and y\ 

      t = -0.4676, df = 32.36, p-value = 0.6432

      alternative hypothesis: true difference in means is not equal to 0\ 

      95 percent confidence interval:

      \ -0.9666928 \ 0.6055888\ 

      sample estimates:

      mean of x mean of y\ 

      \ 9.842836 10.023388\ 
    </output>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      \;
    </input>
  </session>>

  <subsection|A non-parametric test of means>

  Non-parametric tests don't assume anything about the distribution of the
  variable - they use only the rank of the data.

  The wilcoxon test calculates the rank of all samples, and then sums the
  ranks of the smaller sample, and does various things with them

  <with|prog-language|r|prog-session|default|<\session>
    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      wilcox.test(x,y)
    </input>

    <\output>
      \;

      \ \ \ \ \ \ \ \ Wilcoxon rank sum test

      \;

      data: \ x and y\ 

      W = 184, p-value = 0.6783

      alternative hypothesis: true mu is not equal to 0\ 
    </output>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      \;
    </input>
  </session>>

  The wilcox test is slightly weaker than the t-test, because it doesn't take
  into account that the data is normal.

  \;

  <subsection|The Kolmogorov-Smirnov test>

  This is a very nice test that compares two distributions. It will differ
  even if the mean is the same but the variance is different.

  <with|prog-language|r|prog-session|default|<\session>
    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      plot(sort(x),1:length(x),type="l")
    </input>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      lines(sort(y),1:length(y),col=2);v()
    </input>

    <\output>
      <postscript|<tuple|<#252150532D41646F62652D332E3020455053462D332E300A2525446F63756D656E744E65656465645265736F75726365733A20666F6E742048656C7665746963610A25252B20666F6E742048656C7665746963612D426F6C640A25252B20666F6E742048656C7665746963612D4F626C697175650A25252B20666F6E742048656C7665746963612D426F6C644F626C697175650A25252B20666F6E742053796D626F6C0A25255469746C653A2052204772617068696373204F75747075740A252543726561746F723A205220536F6674776172650A252550616765733A20286174656E64290A2525426F756E64696E67426F783A203136322032353220343530203534300A2525456E64436F6D6D656E74730A2525426567696E50726F6C6F670A2F627020207B206773206773207D206465660A2520626567696E202E70732E70726F6C6F670A2F677320207B206773617665207D206465660A2F677220207B2067726573746F7265207D206465660A2F657020207B2073686F7770616765206772206772207D206465660A2F6D2020207B206D6F7665746F207D206465660A2F6C20207B20726C696E65746F207D206465660A2F6E7020207B206E657770617468207D206465660A2F637020207B20636C6F736570617468207D206465660A2F662020207B2066696C6C207D206465660A2F6F2020207B207374726F6B65207D206465660A2F632020207B206E65777061746820302033363020617263207D206465660A2F722020207B2034203220726F6C6C206D6F7665746F203120636F70792033202D3120726F6C6C20657863682030206578636820726C696E65746F203020726C696E65746F202D31206D756C2030206578636820726C696E65746F20636C6F736570617468207D206465660A2F703120207B207374726F6B65207D206465660A2F703220207B20677361766520626720736574726762636F6C6F722066696C6C2067726573746F7265206E657770617468207D206465660A2F703320207B20677361766520626720736574726762636F6C6F722066696C6C2067726573746F7265207374726F6B65207D206465660A2F742020207B2036202D3220726F6C6C206D6F7665746F20677361766520726F746174650A202020202020207073206D756C206E656720302032203120726F6C6C20726D6F7665746F0A202020202020203120696E64657820737472696E67776964746820706F700A202020202020206D756C206E6567203020726D6F7665746F2073686F772067726573746F7265207D206465660A2F636C20207B2067726573746F7265206773617665206E657770617468203320696E646578203320696E646578206D6F7665746F203120696E6465780A2020202020202034202D3120726F6C6C206C696E65746F202065786368203120696E646578206C696E65746F206C696E65746F0A20202020202020636C6F73657061746820636C6970206E657770617468207D206465660A2F726762207B20736574726762636F6C6F72207D206465660A2F732020207B207363616C65666F6E7420736574666F6E74207D206465660A2520656E642020202E70732E70726F6C6F670A2525496E636C7564655265736F757263653A20666F6E742048656C7665746963610A2F48656C7665746963612066696E64666F6E740A647570206C656E677468206469637420626567696E0A20207B3120696E646578202F464944206E65207B6465667D207B706F7020706F707D206966656C73657D20666F72616C6C0A20202F456E636F64696E672049534F4C6174696E31456E636F64696E67206465660A202063757272656E74646963740A2020656E640A2F466F6E7431206578636820646566696E65666F6E7420706F700A2525496E636C7564655265736F757263653A20666F6E742048656C7665746963612D426F6C640A2F48656C7665746963612D426F6C642066696E64666F6E740A647570206C656E677468206469637420626567696E0A20207B3120696E646578202F464944206E65207B6465667D207B706F7020706F707D206966656C73657D20666F72616C6C0A20202F456E636F64696E672049534F4C6174696E31456E636F64696E67206465660A202063757272656E74646963740A2020656E640A2F466F6E7432206578636820646566696E65666F6E7420706F700A2525496E636C7564655265736F757263653A20666F6E742048656C7665746963612D4F626C697175650A2F48656C7665746963612D4F626C697175652066696E64666F6E740A647570206C656E677468206469637420626567696E0A20207B3120696E646578202F464944206E65207B6465667D207B706F7020706F707D206966656C73657D20666F72616C6C0A20202F456E636F64696E672049534F4C6174696E31456E636F64696E67206465660A202063757272656E74646963740A2020656E640A2F466F6E7433206578636820646566696E65666F6E7420706F700A2525496E636C7564655265736F757263653A20666F6E742048656C7665746963612D426F6C644F626C697175650A2F48656C7665746963612D426F6C644F626C697175652066696E64666F6E740A647570206C656E677468206469637420626567696E0A20207B3120696E646578202F464944206E65207B6465667D207B706F7020706F707D206966656C73657D20666F72616C6C0A20202F456E636F64696E672049534F4C6174696E31456E636F64696E67206465660A202063757272656E74646963740A2020656E640A2F466F6E7434206578636820646566696E65666F6E7420706F700A2525496E636C7564655265736F757263653A20666F6E742053796D626F6C0A2F53796D626F6C2066696E64666F6E740A647570206C656E677468206469637420626567696E0A20207B3120696E646578202F464944206E65207B6465667D207B706F7020706F707D206966656C73657D20666F72616C6C0A202063757272656E74646963740A2020656E640A2F466F6E7435206578636820646566696E65666F6E7420706F700A2525456E6450726F6C6F670A2525506167653A203120310A62700A3231312E3230203331332E3230203432342E3830203439302E383020636C0A3020302030207267620A302E3735207365746C696E6577696474680A5B5D203020736574646173680A31207365746C696E656361700A31207365746C696E656A6F696E0A31302E3030207365746D697465726C696D69740A6E700A3231392E3131203331392E3738206D0A31392E373220382E3635206C0A31312E323120382E3636206C0A36332E353720382E3635206C0A31382E343520382E3636206C0A392E333720382E3635206C0A312E333420382E3636206C0A362E363620382E3635206C0A312E303520382E3636206C0A302E363220382E3635206C0A322E383720382E3636206C0A322E313720382E3635206C0A302E363420382E3636206C0A31312E353320382E3635206C0A332E313420382E3636206C0A382E303120382E3635206C0A322E353120382E3636206C0A372E383020382E3635206C0A32332E323020382E3636206C0A332E393220382E3635206C0A6F0A3136322E3030203235322E3030203435302E3030203534302E303020636C0A3020302030207267620A302E3735207365746C696E6577696474680A5B5D203020736574646173680A31207365746C696E656361700A31207365746C696E656A6F696E0A31302E3030207365746D697465726C696D69740A6E700A3233392E3039203331332E3230206D0A3137302E35312030206C0A6F0A6E700A3233392E3039203331332E3230206D0A30202D362E3030206C0A6F0A6E700A3236372E3531203331332E3230206D0A30202D362E3030206C0A6F0A6E700A3239352E3933203331332E3230206D0A30202D362E3030206C0A6F0A6E700A3332342E3334203331332E3230206D0A30202D362E3030206C0A6F0A6E700A3335322E3736203331332E3230206D0A30202D362E3030206C0A6F0A6E700A3338312E3138203331332E3230206D0A30202D362E3030206C0A6F0A6E700A3430392E3630203331332E3230206D0A30202D362E3030206C0A6F0A2F707320313220646566202F466F6E74312066696E64666F6E7420313220730A3233392E3039203239312E36302028382E3029202E352030203020740A3236372E3531203239312E36302028382E3529202E352030203020740A3239352E3933203239312E36302028392E3029202E352030203020740A3332342E3334203239312E36302028392E3529202E352030203020740A3338312E3138203239312E3630202831302E3529202E352030203020740A6E700A3231312E3230203335342E3430206D0A30203132392E3832206C0A6F0A6E700A3231312E3230203335342E3430206D0A2D362E30302030206C0A6F0A6E700A3231312E3230203339372E3637206D0A2D362E30302030206C0A6F0A6E700A3231312E3230203434302E3935206D0A2D362E30302030206C0A6F0A6E700A3231312E3230203438342E3232206D0A2D362E30302030206C0A6F0A3139362E3830203335342E343020283529202E35203020393020740A3139362E3830203339372E36372028313029202E35203020393020740A3139362E3830203434302E39352028313529202E35203020393020740A3139362E3830203438342E32322028323029202E35203020393020740A6E700A3231312E3230203331332E3230206D0A3231332E36302030206C0A30203137372E3630206C0A2D3231332E36302030206C0A30202D3137372E3630206C0A6F0A3136322E3030203235322E3030203435302E3030203534302E303020636C0A2F707320313220646566202F466F6E74312066696E64666F6E7420313220730A3020302030207267620A3331382E3030203236372E36302028736F72745C28785C2929202E352030203020740A3137322E3830203430322E30302028313A6C656E6774685C28785C2929202E35203020393020740A3231312E3230203331332E3230203432342E3830203439302E383020636C0A3120302030207267620A302E3735207365746C696E6577696474680A5B5D203020736574646173680A31207365746C696E656361700A31207365746C696E656A6F696E0A31302E3030207365746D697465726C696D69740A6E700A3136322E3030203332312E3635206D0A3130312E343420362E3738206C0A32332E343820382E3636206C0A302E313220382E3635206C0A31312E353620382E3636206C0A31322E303820382E3635206C0A322E323520382E3636206C0A362E313020382E3635206C0A382E323420382E3636206C0A32312E373620382E3635206C0A32382E373920382E3636206C0A342E363920382E3635206C0A332E323320382E3636206C0A31322E353520382E3635206C0A31312E363320382E3636206C0A302E363720382E3635206C0A32312E363520382E3636206C0A312E333320382E3635206C0A31362E343320332E3534206C0A6F0A65700A2525547261696C65720A252550616765733A20310A2525454F460A>|ps>||||||>
    </output>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      \;
    </input>
  </session>>

  The kolmogov-smirnov test finds the point at which the proportion of points
  is most different, and looks at that maximal difference.

  <with|prog-language|r|prog-session|default|<\session>
    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      ks.test(x,y)
    </input>

    <\output>
      \;

      \;

      \ \ \ \ \ \ \ \ Two-sample Kolmogorov-Smirnov test

      \;

      data: \ x and y\ 

      \;

      D = 0.3, p-value = 0.3356

      alternative hypothesis: two.sided\ 
    </output>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      \;
    </input>
  </session>>

  <subsection|Understanding magic>

  Let us look at the following curious thing:

  <with|prog-language|r|prog-session|default|<\session>
    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      x=rnorm(100)
    </input>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      y=rnorm(100,sd=0.1)+x
    </input>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      k=ks.test(x,y)
    </input>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      k
    </input>

    <\output>
      \;

      \ \ \ \ \ \ \ \ Two-sample Kolmogorov-Smirnov test

      \;

      data: \ x and y\ 

      \;

      D = 0.04, p-value = 1

      alternative hypothesis: two.sided\ 
    </output>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      print(k)
    </input>

    <\output>
      \;

      \ \ \ \ \ \ \ \ Two-sample Kolmogorov-Smirnov test

      \;

      data: \ x and y\ 

      \;

      D = 0.04, p-value = 1

      alternative hypothesis: two.sided\ 
    </output>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      \;
    </input>
  </session>>

  If everything in R is vectors or lists, why is the result of the KS test
  printed like this?

  The magic is the following:

  Even though things are always vectors or lists, they can have a ''class''.
  To see the class of an object, we can use the <verbatim|class()> function:

  <with|prog-language|r|prog-session|default|<\session>
    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      class(k)
    </input>

    <\output>
      [1] "htest"
    </output>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      \;
    </input>
  </session>>

  And now the trick:

  When we say <verbatim|print(k)>, the actual function that is called is
  <verbatim|print.htest()> for k, and <verbatim|print.table()> for s.

  <with|prog-language|r|prog-session|default|<\session>
    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      print.htest(k)
    </input>

    <\output>
      \;

      \ \ \ \ \ \ \ \ Two-sample Kolmogorov-Smirnov test

      \;

      data: \ x and y\ 

      D = 0.38, p-value = 1.071e-06

      alternative hypothesis: two.sided\ 
    </output>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      print.table(s)
    </input>

    <\output>
      \ \ \ \ Min. \ 1st Qu. \ \ Median \ \ \ \ Mean \ 3rd Qu. \ \ \ \ Max.\ 

      -2.22700 -0.57190 -0.08799 \ 0.01895 \ 0.72390 \ 2.04100\ 
    </output>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      print.htest(s)
    </input>

    <\output>
      \;

      Error in strsplit(x, as.character(split), as.logical(extended)) :\ 

      \ \ \ \ \ \ \ \ non-character argument in strsplit()
    </output>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      print
    </input>

    <\output>
      function (x, ...)\ 

      UseMethod("print")

      \<less\>environment: namespace:base\<gtr\>
    </output>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      \;
    </input>
  </session>>

  All this is not very important, yet.

  It only matters if we want to understand what function is called.

  <with|prog-language|r|prog-session|default|<\session>
    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      help(print.htest)
    </input>

    <\output>
      help() for print.htest \ is shown in browser netscape ...

      Use \ \ \ \ \ help( print.htest , htmlhelp=FALSE)

      or \ \ \ \ \ \ options(htmlhelp = FALSE)

      to revert.

      Warning message:\ 

      Using non-linked HTML file: style sheet and hyperlinks may be incorrect
      in: help(print.htest)\ 
    </output>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      \;
    </input>
  </session>>

  Another function that depends on its input is <verbatim|plot()>.

  <with|prog-language|r|prog-session|default|<\session>
    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      plot
    </input>

    <\output>
      function (x, y, ...)\ 

      {

      \ \ \ \ if (is.null(attr(x, "class")) && is.function(x)) {

      \ \ \ \ \ \ \ \ nms \<less\>- names(list(...))

      \ \ \ \ \ \ \ \ if (missing(y))\ 

      \ \ \ \ \ \ \ \ \ \ \ \ y \<less\>- {

      \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ if (!"from" %in% nms)\ 

      \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0

      \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ else if (!"to" %in% nms)\ 

      \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 1

      \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ else if (!"xlim" %in% nms)\ 

      \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ NULL

      \ \ \ \ \ \ \ \ \ \ \ \ }

      \ \ \ \ \ \ \ \ if ("ylab" %in% nms)\ 

      \ \ \ \ \ \ \ \ \ \ \ \ plot.function(x, y, ...)

      \ \ \ \ \ \ \ \ else plot.function(x, y, ylab =
      paste(deparse(substitute(x)),\ 

      \ \ \ \ \ \ \ \ \ \ \ \ "(x)"), ...)

      \ \ \ \ }

      \ \ \ \ else UseMethod("plot")

      }

      \<less\>environment: namespace:graphics\<gtr\>
    </output>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      plot(x,y);v()
    </input>

    <\output>
      <postscript|<tuple|<#252150532D41646F62652D332E3020455053462D332E300A2525446F63756D656E744E65656465645265736F75726365733A20666F6E742048656C7665746963610A25252B20666F6E742048656C7665746963612D426F6C640A25252B20666F6E742048656C7665746963612D4F626C697175650A25252B20666F6E742048656C7665746963612D426F6C644F626C697175650A25252B20666F6E742053796D626F6C0A25255469746C653A2052204772617068696373204F75747075740A252543726561746F723A205220536F6674776172650A252550616765733A20286174656E64290A2525426F756E64696E67426F783A203136322032353220343530203534300A2525456E64436F6D6D656E74730A2525426567696E50726F6C6F670A2F627020207B206773206773207D206465660A2520626567696E202E70732E70726F6C6F670A2F677320207B206773617665207D206465660A2F677220207B2067726573746F7265207D206465660A2F657020207B2073686F7770616765206772206772207D206465660A2F6D2020207B206D6F7665746F207D206465660A2F6C20207B20726C696E65746F207D206465660A2F6E7020207B206E657770617468207D206465660A2F637020207B20636C6F736570617468207D206465660A2F662020207B2066696C6C207D206465660A2F6F2020207B207374726F6B65207D206465660A2F632020207B206E65777061746820302033363020617263207D206465660A2F722020207B2034203220726F6C6C206D6F7665746F203120636F70792033202D3120726F6C6C20657863682030206578636820726C696E65746F203020726C696E65746F202D31206D756C2030206578636820726C696E65746F20636C6F736570617468207D206465660A2F703120207B207374726F6B65207D206465660A2F703220207B20677361766520626720736574726762636F6C6F722066696C6C2067726573746F7265206E657770617468207D206465660A2F703320207B20677361766520626720736574726762636F6C6F722066696C6C2067726573746F7265207374726F6B65207D206465660A2F742020207B2036202D3220726F6C6C206D6F7665746F20677361766520726F746174650A202020202020207073206D756C206E656720302032203120726F6C6C20726D6F7665746F0A202020202020203120696E64657820737472696E67776964746820706F700A202020202020206D756C206E6567203020726D6F7665746F2073686F772067726573746F7265207D206465660A2F636C20207B2067726573746F7265206773617665206E657770617468203320696E646578203320696E646578206D6F7665746F203120696E6465780A2020202020202034202D3120726F6C6C206C696E65746F202065786368203120696E646578206C696E65746F206C696E65746F0A20202020202020636C6F73657061746820636C6970206E657770617468207D206465660A2F726762207B20736574726762636F6C6F72207D206465660A2F732020207B207363616C65666F6E7420736574666F6E74207D206465660A2520656E642020202E70732E70726F6C6F670A2525496E636C7564655265736F757263653A20666F6E742048656C7665746963610A2F48656C7665746963612066696E64666F6E740A647570206C656E677468206469637420626567696E0A20207B3120696E646578202F464944206E65207B6465667D207B706F7020706F707D206966656C73657D20666F72616C6C0A20202F456E636F64696E672049534F4C6174696E31456E636F64696E67206465660A202063757272656E74646963740A2020656E640A2F466F6E7431206578636820646566696E65666F6E7420706F700A2525496E636C7564655265736F757263653A20666F6E742048656C7665746963612D426F6C640A2F48656C7665746963612D426F6C642066696E64666F6E740A647570206C656E677468206469637420626567696E0A20207B3120696E646578202F464944206E65207B6465667D207B706F7020706F707D206966656C73657D20666F72616C6C0A20202F456E636F64696E672049534F4C6174696E31456E636F64696E67206465660A202063757272656E74646963740A2020656E640A2F466F6E7432206578636820646566696E65666F6E7420706F700A2525496E636C7564655265736F757263653A20666F6E742048656C7665746963612D4F626C697175650A2F48656C7665746963612D4F626C697175652066696E64666F6E740A647570206C656E677468206469637420626567696E0A20207B3120696E646578202F464944206E65207B6465667D207B706F7020706F707D206966656C73657D20666F72616C6C0A20202F456E636F64696E672049534F4C6174696E31456E636F64696E67206465660A202063757272656E74646963740A2020656E640A2F466F6E7433206578636820646566696E65666F6E7420706F700A2525496E636C7564655265736F757263653A20666F6E742048656C7665746963612D426F6C644F626C697175650A2F48656C7665746963612D426F6C644F626C697175652066696E64666F6E740A647570206C656E677468206469637420626567696E0A20207B3120696E646578202F464944206E65207B6465667D207B706F7020706F707D206966656C73657D20666F72616C6C0A20202F456E636F64696E672049534F4C6174696E31456E636F64696E67206465660A202063757272656E74646963740A2020656E640A2F466F6E7434206578636820646566696E65666F6E7420706F700A2525496E636C7564655265736F757263653A20666F6E742053796D626F6C0A2F53796D626F6C2066696E64666F6E740A647570206C656E677468206469637420626567696E0A20207B3120696E646578202F464944206E65207B6465667D207B706F7020706F707D206966656C73657D20666F72616C6C0A202063757272656E74646963740A2020656E640A2F466F6E7435206578636820646566696E65666F6E7420706F700A2525456E6450726F6C6F670A2525506167653A203120310A62700A3231312E3230203331332E3230203432342E3830203439302E383020636C0A3231312E3230203331332E3230203432342E3830203439302E383020636C0A3020302030207267620A302E3735207365746C696E6577696474680A5B5D203020736574646173680A31207365746C696E656361700A31207365746C696E656A6F696E0A31302E3030207365746D697465726C696D69740A3236342E3238203334382E343020322E323520632070310A3238312E3537203337302E383520322E323520632070310A3333362E3238203431322E373720322E323520632070310A3336302E3636203433382E353020322E323520632070310A3332312E3638203339392E353320322E323520632070310A3236302E3835203335352E363320322E323520632070310A3336392E3630203434392E303520322E323520632070310A3339302E3230203435392E323020322E323520632070310A3239322E3539203337372E353520322E323520632070310A3330362E3636203338382E363220322E323520632070310A3334322E3633203432302E373420322E323520632070310A3239302E3936203337322E383520322E323520632070310A3332392E3438203430332E363620322E323520632070310A3236372E3131203335342E393620322E323520632070310A3333372E3138203431362E353720322E323520632070310A3238342E3433203336352E333620322E323520632070310A3333382E3430203430382E313920322E323520632070310A3331382E3431203430302E373520322E323520632070310A3330362E3432203338312E343020322E323520632070310A3333372E3739203431372E323020322E323520632070310A3236322E3039203335352E323620322E323520632070310A3331332E3131203339362E353520322E323520632070310A3234312E3037203332382E363420322E323520632070310A3330312E3637203338322E363320322E323520632070310A3332362E3332203430312E393020322E323520632070310A3431362E3839203438342E323220322E323520632070310A3334372E3831203432372E383020322E323520632070310A3231392E3131203331392E373820322E323520632070310A3337342E3130203435332E333620322E323520632070310A3233312E3635203332392E323620322E323520632070310A3338362E3038203435372E363520322E323520632070310A3331312E3937203339342E363520322E323520632070310A3333342E3934203431332E303920322E323520632070310A3238382E3432203337312E393720322E323520632070310A3333372E3334203431382E303020322E323520632070310A3336392E3939203433372E393920322E323520632070310A3233352E3039203333332E383820322E323520632070310A3233332E3138203332352E303720322E323520632070310A3233312E3933203332392E343420322E323520632070310A3334302E3930203431352E323520322E323520632070310A3335302E3239203432332E383720322E323520632070310A3338352E3735203435332E353520322E323520632070310A3332352E3336203339382E333520322E323520632070310A3237392E3639203336362E323720322E323520632070310A3334392E3437203432302E303420322E323520632070310A3332342E3438203430342E323420322E323520632070310A3333342E3634203430382E383620322E323520632070310A3333362E3439203430362E363720322E323520632070310A3333392E3531203431322E323520322E323520632070310A3330342E3939203338382E333720322E323520632070310A3237332E3232203336322E303720322E323520632070310A3334332E3130203432302E353720322E323520632070310A3331362E3739203430302E323420322E323520632070310A3236322E3430203335332E303020322E323520632070310A3334392E3634203432362E303320322E323520632070310A3237372E3338203336312E323020322E323520632070310A3330382E3430203338372E313920322E323520632070310A3332322E3036203339362E353720322E323520632070310A3236362E3535203334372E383620322E323520632070310A3331312E3837203339322E383920322E323520632070310A3331302E3630203339322E373320322E323520632070310A3238362E3437203337342E353520322E323520632070310A3236312E3737203335312E343320322E323520632070310A3232362E3936203332312E313920322E323520632070310A3238372E3038203336382E383220322E323520632070310A3333362E3733203431342E353820322E323520632070310A3239382E3831203337392E353720322E323520632070310A3238382E3238203337322E303920322E323520632070310A3239372E3838203338372E343820322E323520632070310A3332302E3130203339372E363220322E323520632070310A3331332E3730203339392E343420322E323520632070310A3333312E3633203430392E393920322E323520632070310A3330382E3333203338382E323520322E323520632070310A3334372E3631203432352E313920322E323520632070310A3334302E3739203431352E323820322E323520632070310A3236302E3438203335342E353120322E323520632070310A3333302E3239203431312E393420322E323520632070310A3234392E3834203333372E353120322E323520632070310A3330392E3734203339312E363520322E323520632070310A3331392E3531203430312E353320322E323520632070310A3239332E3637203337352E303920322E323520632070310A3332322E3638203430332E343320322E323520632070310A3239332E3935203338332E313520322E323520632070310A3237312E3932203335382E323620322E323520632070310A3338362E3538203435342E333820322E323520632070310A3430302E3035203436392E363020322E323520632070310A3235382E3532203334352E313920322E323520632070310A3239302E3530203337362E383020322E323520632070310A3234392E3733203334322E343820322E323520632070310A3334362E3337203432352E313420322E323520632070310A3238382E3835203337312E353220322E323520632070310A3337352E3634203434372E303620322E323520632070310A3239302E3933203337372E323420322E323520632070310A3239382E3234203338302E343920322E323520632070310A3333392E3432203431372E343120322E323520632070310A3330362E3933203339332E353820322E323520632070310A3330342E3433203338342E303120322E323520632070310A3239312E3738203337322E383720322E323520632070310A3237372E3334203336342E373820322E323520632070310A3236372E3730203335372E383120322E323520632070310A3136322E3030203235322E3030203435302E3030203534302E303020636C0A3020302030207267620A302E3735207365746C696E6577696474680A5B5D203020736574646173680A31207365746C696E656361700A31207365746C696E656A6F696E0A31302E3030207365746D697465726C696D69740A6E700A3232312E3835203331332E3230206D0A3139302E38302030206C0A6F0A6E700A3232312E3835203331332E3230206D0A30202D362E3030206C0A6F0A6E700A3236302E3031203331332E3230206D0A30202D362E3030206C0A6F0A6E700A3239382E3137203331332E3230206D0A30202D362E3030206C0A6F0A6E700A3333362E3333203331332E3230206D0A30202D362E3030206C0A6F0A6E700A3337342E3439203331332E3230206D0A30202D362E3030206C0A6F0A6E700A3431322E3635203331332E3230206D0A30202D362E3030206C0A6F0A2F707320313220646566202F466F6E74312066696E64666F6E7420313220730A3232312E3835203239312E363020282D3229202E352030203020740A3236302E3031203239312E363020282D3129202E352030203020740A3239382E3137203239312E363020283029202E352030203020740A3333362E3333203239312E363020283129202E352030203020740A3337342E3439203239312E363020283229202E352030203020740A3431322E3635203239312E363020283329202E352030203020740A6E700A3231312E3230203331362E3831206D0A30203136312E3638206C0A6F0A6E700A3231312E3230203331362E3831206D0A2D362E30302030206C0A6F0A6E700A3231312E3230203334392E3134206D0A2D362E30302030206C0A6F0A6E700A3231312E3230203338312E3438206D0A2D362E30302030206C0A6F0A6E700A3231312E3230203431332E3831206D0A2D362E30302030206C0A6F0A6E700A3231312E3230203434362E3135206D0A2D362E30302030206C0A6F0A6E700A3231312E3230203437382E3439206D0A2D362E30302030206C0A6F0A3139362E3830203331362E383120282D3229202E35203020393020740A3139362E3830203334392E313420282D3129202E35203020393020740A3139362E3830203338312E343820283029202E35203020393020740A3139362E3830203431332E383120283129202E35203020393020740A3139362E3830203434362E313520283229202E35203020393020740A3139362E3830203437382E343920283329202E35203020393020740A6E700A3231312E3230203331332E3230206D0A3231332E36302030206C0A30203137372E3630206C0A2D3231332E36302030206C0A30202D3137372E3630206C0A6F0A3136322E3030203235322E3030203435302E3030203534302E303020636C0A2F707320313220646566202F466F6E74312066696E64666F6E7420313220730A3020302030207267620A3331382E3030203236372E363020287829202E352030203020740A3137322E3830203430322E303020287929202E35203020393020740A65700A2525547261696C65720A252550616765733A20310A2525454F460A>|ps>||||||>
    </output>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      z=as.factor( x\<gtr\>0 )
    </input>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      plot(z,x);v()
    </input>

    <\output>
      <postscript|<tuple|<#252150532D41646F62652D332E3020455053462D332E300A2525446F63756D656E744E65656465645265736F75726365733A20666F6E742048656C7665746963610A25252B20666F6E742048656C7665746963612D426F6C640A25252B20666F6E742048656C7665746963612D4F626C697175650A25252B20666F6E742048656C7665746963612D426F6C644F626C697175650A25252B20666F6E742053796D626F6C0A25255469746C653A2052204772617068696373204F75747075740A252543726561746F723A205220536F6674776172650A252550616765733A20286174656E64290A2525426F756E64696E67426F783A203136322032353220343530203534300A2525456E64436F6D6D656E74730A2525426567696E50726F6C6F670A2F627020207B206773206773207D206465660A2520626567696E202E70732E70726F6C6F670A2F677320207B206773617665207D206465660A2F677220207B2067726573746F7265207D206465660A2F657020207B2073686F7770616765206772206772207D206465660A2F6D2020207B206D6F7665746F207D206465660A2F6C20207B20726C696E65746F207D206465660A2F6E7020207B206E657770617468207D206465660A2F637020207B20636C6F736570617468207D206465660A2F662020207B2066696C6C207D206465660A2F6F2020207B207374726F6B65207D206465660A2F632020207B206E65777061746820302033363020617263207D206465660A2F722020207B2034203220726F6C6C206D6F7665746F203120636F70792033202D3120726F6C6C20657863682030206578636820726C696E65746F203020726C696E65746F202D31206D756C2030206578636820726C696E65746F20636C6F736570617468207D206465660A2F703120207B207374726F6B65207D206465660A2F703220207B20677361766520626720736574726762636F6C6F722066696C6C2067726573746F7265206E657770617468207D206465660A2F703320207B20677361766520626720736574726762636F6C6F722066696C6C2067726573746F7265207374726F6B65207D206465660A2F742020207B2036202D3220726F6C6C206D6F7665746F20677361766520726F746174650A202020202020207073206D756C206E656720302032203120726F6C6C20726D6F7665746F0A202020202020203120696E64657820737472696E67776964746820706F700A202020202020206D756C206E6567203020726D6F7665746F2073686F772067726573746F7265207D206465660A2F636C20207B2067726573746F7265206773617665206E657770617468203320696E646578203320696E646578206D6F7665746F203120696E6465780A2020202020202034202D3120726F6C6C206C696E65746F202065786368203120696E646578206C696E65746F206C696E65746F0A20202020202020636C6F73657061746820636C6970206E657770617468207D206465660A2F726762207B20736574726762636F6C6F72207D206465660A2F732020207B207363616C65666F6E7420736574666F6E74207D206465660A2520656E642020202E70732E70726F6C6F670A2525496E636C7564655265736F757263653A20666F6E742048656C7665746963610A2F48656C7665746963612066696E64666F6E740A647570206C656E677468206469637420626567696E0A20207B3120696E646578202F464944206E65207B6465667D207B706F7020706F707D206966656C73657D20666F72616C6C0A20202F456E636F64696E672049534F4C6174696E31456E636F64696E67206465660A202063757272656E74646963740A2020656E640A2F466F6E7431206578636820646566696E65666F6E7420706F700A2525496E636C7564655265736F757263653A20666F6E742048656C7665746963612D426F6C640A2F48656C7665746963612D426F6C642066696E64666F6E740A647570206C656E677468206469637420626567696E0A20207B3120696E646578202F464944206E65207B6465667D207B706F7020706F707D206966656C73657D20666F72616C6C0A20202F456E636F64696E672049534F4C6174696E31456E636F64696E67206465660A202063757272656E74646963740A2020656E640A2F466F6E7432206578636820646566696E65666F6E7420706F700A2525496E636C7564655265736F757263653A20666F6E742048656C7665746963612D4F626C697175650A2F48656C7665746963612D4F626C697175652066696E64666F6E740A647570206C656E677468206469637420626567696E0A20207B3120696E646578202F464944206E65207B6465667D207B706F7020706F707D206966656C73657D20666F72616C6C0A20202F456E636F64696E672049534F4C6174696E31456E636F64696E67206465660A202063757272656E74646963740A2020656E640A2F466F6E7433206578636820646566696E65666F6E7420706F700A2525496E636C7564655265736F757263653A20666F6E742048656C7665746963612D426F6C644F626C697175650A2F48656C7665746963612D426F6C644F626C697175652066696E64666F6E740A647570206C656E677468206469637420626567696E0A20207B3120696E646578202F464944206E65207B6465667D207B706F7020706F707D206966656C73657D20666F72616C6C0A20202F456E636F64696E672049534F4C6174696E31456E636F64696E67206465660A202063757272656E74646963740A2020656E640A2F466F6E7434206578636820646566696E65666F6E7420706F700A2525496E636C7564655265736F757263653A20666F6E742053796D626F6C0A2F53796D626F6C2066696E64666F6E740A647570206C656E677468206469637420626567696E0A20207B3120696E646578202F464944206E65207B6465667D207B706F7020706F707D206966656C73657D20666F72616C6C0A202063757272656E74646963740A2020656E640A2F466F6E7435206578636820646566696E65666F6E7420706F700A2525456E6450726F6C6F670A2525506167653A203120310A62700A3231312E3230203331332E3230203432342E3830203439302E383020636C0A3231312E3230203331332E3230203432342E3830203439302E383020636C0A3020302030207267620A322E3235207365746C696E6577696474680A5B5D203020736574646173680A31207365746C696E656361700A31207365746C696E656A6F696E0A31302E3030207365746D697465726C696D69740A6E700A3232392E3030203336332E3638206D0A37392E31312030206C0A6F0A302E3735207365746C696E6577696474680A5B20332E303020352E30305D203020736574646173680A6E700A3236382E3536203331392E3738206D0A302033332E3538206C0A6F0A6E700A3236382E3536203338352E3237206D0A30202D372E3932206C0A6F0A302E3735207365746C696E6577696474680A5B5D203020736574646173680A6E700A3234382E3738203331392E3738206D0A33392E35352030206C0A6F0A6E700A3234382E3738203338352E3237206D0A33392E35352030206C0A6F0A6E700A3234382E3738203331392E3738206D0A33392E35352030206C0A6F0A6E700A3234382E3738203338352E3237206D0A33392E35352030206C0A6F0A6E700A3232392E3030203335332E3336206D0A37392E31312030206C0A302032332E3939206C0A2D37392E31312030206C0A30202D32332E3939206C0A6F0A322E3235207365746C696E6577696474680A5B5D203020736574646173680A6E700A3332372E3839203431362E3039206D0A37392E31312030206C0A6F0A302E3735207365746C696E6577696474680A5B20332E303020352E30305D203020736574646173680A6E700A3336372E3434203338352E3537206D0A302031322E3836206C0A6F0A6E700A3336372E3434203436322E3034206D0A30202D33352E3432206C0A6F0A302E3735207365746C696E6577696474680A5B5D203020736574646173680A6E700A3334372E3637203338352E3537206D0A33392E35352030206C0A6F0A6E700A3334372E3637203436322E3034206D0A33392E35352030206C0A6F0A6E700A3334372E3637203338352E3537206D0A33392E35352030206C0A6F0A6E700A3334372E3637203436322E3034206D0A33392E35352030206C0A6F0A6E700A3332372E3839203339382E3433206D0A37392E31312030206C0A302032382E3139206C0A2D37392E31312030206C0A30202D32382E3139206C0A6F0A3336372E3434203438342E323220322E323520632070310A3336372E3434203437302E323220322E323520632070310A3136322E3030203235322E3030203435302E3030203534302E303020636C0A3020302030207267620A302E3735207365746C696E6577696474680A5B5D203020736574646173680A31207365746C696E656361700A31207365746C696E656A6F696E0A31302E3030207365746D697465726C696D69740A6E700A3236382E3536203331332E3230206D0A39382E38382030206C0A6F0A6E700A3236382E3536203331332E3230206D0A30202D362E3030206C0A6F0A6E700A3336372E3434203331332E3230206D0A30202D362E3030206C0A6F0A2F707320313220646566202F466F6E74312066696E64666F6E7420313220730A3236382E3536203239312E3630202846414C534529202E352030203020740A3336372E3434203239312E363020285452554529202E352030203020740A6E700A3231312E3230203332322E3036206D0A30203135382E3633206C0A6F0A6E700A3231312E3230203332322E3036206D0A2D362E30302030206C0A6F0A6E700A3231312E3230203335332E3738206D0A2D362E30302030206C0A6F0A6E700A3231312E3230203338352E3531206D0A2D362E30302030206C0A6F0A6E700A3231312E3230203431372E3234206D0A2D362E30302030206C0A6F0A6E700A3231312E3230203434382E3937206D0A2D362E30302030206C0A6F0A6E700A3231312E3230203438302E3639206D0A2D362E30302030206C0A6F0A3139362E3830203332322E303620282D3229202E35203020393020740A3139362E3830203335332E373820282D3129202E35203020393020740A3139362E3830203338352E353120283029202E35203020393020740A3139362E3830203431372E323420283129202E35203020393020740A3139362E3830203434382E393720283229202E35203020393020740A3139362E3830203438302E363920283329202E35203020393020740A6E700A3231312E3230203331332E3230206D0A3231332E36302030206C0A30203137372E3630206C0A2D3231332E36302030206C0A30202D3137372E3630206C0A6F0A65700A2525547261696C65720A252550616765733A20310A2525454F460A>|ps>||||||>
    </output>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      plot(sin,from=-3,to=3);v()
    </input>

    <\output>
      <postscript|<tuple|<#252150532D41646F62652D332E3020455053462D332E300A2525446F63756D656E744E65656465645265736F75726365733A20666F6E742048656C7665746963610A25252B20666F6E742048656C7665746963612D426F6C640A25252B20666F6E742048656C7665746963612D4F626C697175650A25252B20666F6E742048656C7665746963612D426F6C644F626C697175650A25252B20666F6E742053796D626F6C0A25255469746C653A2052204772617068696373204F75747075740A252543726561746F723A205220536F6674776172650A252550616765733A20286174656E64290A2525426F756E64696E67426F783A203136322032353220343530203534300A2525456E64436F6D6D656E74730A2525426567696E50726F6C6F670A2F627020207B206773206773207D206465660A2520626567696E202E70732E70726F6C6F670A2F677320207B206773617665207D206465660A2F677220207B2067726573746F7265207D206465660A2F657020207B2073686F7770616765206772206772207D206465660A2F6D2020207B206D6F7665746F207D206465660A2F6C20207B20726C696E65746F207D206465660A2F6E7020207B206E657770617468207D206465660A2F637020207B20636C6F736570617468207D206465660A2F662020207B2066696C6C207D206465660A2F6F2020207B207374726F6B65207D206465660A2F632020207B206E65777061746820302033363020617263207D206465660A2F722020207B2034203220726F6C6C206D6F7665746F203120636F70792033202D3120726F6C6C20657863682030206578636820726C696E65746F203020726C696E65746F202D31206D756C2030206578636820726C696E65746F20636C6F736570617468207D206465660A2F703120207B207374726F6B65207D206465660A2F703220207B20677361766520626720736574726762636F6C6F722066696C6C2067726573746F7265206E657770617468207D206465660A2F703320207B20677361766520626720736574726762636F6C6F722066696C6C2067726573746F7265207374726F6B65207D206465660A2F742020207B2036202D3220726F6C6C206D6F7665746F20677361766520726F746174650A202020202020207073206D756C206E656720302032203120726F6C6C20726D6F7665746F0A202020202020203120696E64657820737472696E67776964746820706F700A202020202020206D756C206E6567203020726D6F7665746F2073686F772067726573746F7265207D206465660A2F636C20207B2067726573746F7265206773617665206E657770617468203320696E646578203320696E646578206D6F7665746F203120696E6465780A2020202020202034202D3120726F6C6C206C696E65746F202065786368203120696E646578206C696E65746F206C696E65746F0A20202020202020636C6F73657061746820636C6970206E657770617468207D206465660A2F726762207B20736574726762636F6C6F72207D206465660A2F732020207B207363616C65666F6E7420736574666F6E74207D206465660A2520656E642020202E70732E70726F6C6F670A2525496E636C7564655265736F757263653A20666F6E742048656C7665746963610A2F48656C7665746963612066696E64666F6E740A647570206C656E677468206469637420626567696E0A20207B3120696E646578202F464944206E65207B6465667D207B706F7020706F707D206966656C73657D20666F72616C6C0A20202F456E636F64696E672049534F4C6174696E31456E636F64696E67206465660A202063757272656E74646963740A2020656E640A2F466F6E7431206578636820646566696E65666F6E7420706F700A2525496E636C7564655265736F757263653A20666F6E742048656C7665746963612D426F6C640A2F48656C7665746963612D426F6C642066696E64666F6E740A647570206C656E677468206469637420626567696E0A20207B3120696E646578202F464944206E65207B6465667D207B706F7020706F707D206966656C73657D20666F72616C6C0A20202F456E636F64696E672049534F4C6174696E31456E636F64696E67206465660A202063757272656E74646963740A2020656E640A2F466F6E7432206578636820646566696E65666F6E7420706F700A2525496E636C7564655265736F757263653A20666F6E742048656C7665746963612D4F626C697175650A2F48656C7665746963612D4F626C697175652066696E64666F6E740A647570206C656E677468206469637420626567696E0A20207B3120696E646578202F464944206E65207B6465667D207B706F7020706F707D206966656C73657D20666F72616C6C0A20202F456E636F64696E672049534F4C6174696E31456E636F64696E67206465660A202063757272656E74646963740A2020656E640A2F466F6E7433206578636820646566696E65666F6E7420706F700A2525496E636C7564655265736F757263653A20666F6E742048656C7665746963612D426F6C644F626C697175650A2F48656C7665746963612D426F6C644F626C697175652066696E64666F6E740A647570206C656E677468206469637420626567696E0A20207B3120696E646578202F464944206E65207B6465667D207B706F7020706F707D206966656C73657D20666F72616C6C0A20202F456E636F64696E672049534F4C6174696E31456E636F64696E67206465660A202063757272656E74646963740A2020656E640A2F466F6E7434206578636820646566696E65666F6E7420706F700A2525496E636C7564655265736F757263653A20666F6E742053796D626F6C0A2F53796D626F6C2066696E64666F6E740A647570206C656E677468206469637420626567696E0A20207B3120696E646578202F464944206E65207B6465667D207B706F7020706F707D206966656C73657D20666F72616C6C0A202063757272656E74646963740A2020656E640A2F466F6E7435206578636820646566696E65666F6E7420706F700A2525456E6450726F6C6F670A2525506167653A203120310A62700A3231312E3230203331332E3230203432342E3830203439302E383020636C0A3231312E3230203331332E3230203432342E3830203439302E383020636C0A3020302030207267620A302E3735207365746C696E6577696474680A5B5D203020736574646173680A31207365746C696E656361700A31207365746C696E656A6F696E0A31302E3030207365746D697465726C696D69740A6E700A3231392E3131203339302E3430206D0A312E3938202D342E3836206C0A312E3938202D342E3831206C0A312E3937202D342E3732206C0A312E3938202D342E3633206C0A312E3938202D342E3532206C0A312E3938202D342E3430206C0A312E3938202D342E3235206C0A312E3937202D342E3039206C0A312E3938202D332E3933206C0A312E3938202D332E3733206C0A312E3938202D332E3534206C0A312E3937202D332E3332206C0A312E3938202D332E3130206C0A312E3938202D322E3836206C0A312E3938202D322E3632206C0A312E3938202D322E3336206C0A312E3937202D322E3130206C0A312E3938202D312E3832206C0A312E3938202D312E3535206C0A312E3938202D312E3237206C0A312E3937202D302E3937206C0A312E3938202D302E3639206C0A312E3938202D302E3339206C0A312E3938202D302E3039206C0A312E393820302E3230206C0A312E393720302E3530206C0A312E393820302E3739206C0A312E393820312E3038206C0A312E393820312E3336206C0A312E393720312E3635206C0A312E393820312E3933206C0A312E393820322E3139206C0A312E393820322E3435206C0A312E393820322E3731206C0A312E393720322E3935206C0A312E393820332E3138206C0A312E393820332E3430206C0A312E393820332E3631206C0A312E393720332E3831206C0A312E393820332E3938206C0A312E393820342E3135206C0A312E393820342E3331206C0A312E393820342E3434206C0A312E393720342E3536206C0A312E393820342E3637206C0A312E393820342E3735206C0A312E393820342E3833206C0A312E393720342E3838206C0A312E393820342E3931206C0A312E393820342E3933206C0A312E393820342E3933206C0A312E393820342E3931206C0A312E393720342E3838206C0A312E393820342E3833206C0A312E393820342E3735206C0A312E393820342E3637206C0A312E393720342E3536206C0A312E393820342E3434206C0A312E393820342E3331206C0A312E393820342E3135206C0A312E393820332E3938206C0A312E393720332E3831206C0A312E393820332E3631206C0A312E393820332E3430206C0A312E393820332E3138206C0A312E393720322E3935206C0A312E393820322E3731206C0A312E393820322E3435206C0A312E393820322E3139206C0A312E393820312E3933206C0A312E393720312E3635206C0A312E393820312E3336206C0A312E393820312E3038206C0A312E393820302E3739206C0A312E393720302E3530206C0A312E393820302E3230206C0A312E3938202D302E3039206C0A312E3938202D302E3339206C0A312E3938202D302E3639206C0A312E3937202D302E3937206C0A312E3938202D312E3237206C0A312E3938202D312E3535206C0A312E3938202D312E3832206C0A312E3937202D322E3130206C0A312E3938202D322E3336206C0A312E3938202D322E3632206C0A312E3938202D322E3836206C0A312E3938202D332E3130206C0A312E3937202D332E3332206C0A312E3938202D332E3534206C0A312E3938202D332E3733206C0A312E3938202D332E3933206C0A312E3937202D342E3039206C0A312E3938202D342E3235206C0A312E3938202D342E3430206C0A312E3938202D342E3532206C0A312E3938202D342E3633206C0A312E3937202D342E3732206C0A312E3938202D342E3831206C0A3431362E3839203431332E3630206C696E65746F0A6F0A3136322E3030203235322E3030203435302E3030203534302E303020636C0A3020302030207267620A302E3735207365746C696E6577696474680A5B5D203020736574646173680A31207365746C696E656361700A31207365746C696E656A6F696E0A31302E3030207365746D697465726C696D69740A6E700A3231392E3131203331332E3230206D0A3139372E37382030206C0A6F0A6E700A3231392E3131203331332E3230206D0A30202D362E3030206C0A6F0A6E700A3235322E3037203331332E3230206D0A30202D362E3030206C0A6F0A6E700A3238352E3034203331332E3230206D0A30202D362E3030206C0A6F0A6E700A3331382E3030203331332E3230206D0A30202D362E3030206C0A6F0A6E700A3335302E3936203331332E3230206D0A30202D362E3030206C0A6F0A6E700A3338332E3933203331332E3230206D0A30202D362E3030206C0A6F0A6E700A3431362E3839203331332E3230206D0A30202D362E3030206C0A6F0A2F707320313220646566202F466F6E74312066696E64666F6E7420313220730A3231392E3131203239312E363020282D3329202E352030203020740A3235322E3037203239312E363020282D3229202E352030203020740A3238352E3034203239312E363020282D3129202E352030203020740A3331382E3030203239312E363020283029202E352030203020740A3335302E3936203239312E363020283129202E352030203020740A3338332E3933203239312E363020283229202E352030203020740A3431362E3839203239312E363020283329202E352030203020740A6E700A3231312E3230203331392E3737206D0A30203136342E3436206C0A6F0A6E700A3231312E3230203331392E3737206D0A2D362E30302030206C0A6F0A6E700A3231312E3230203336302E3839206D0A2D362E30302030206C0A6F0A6E700A3231312E3230203430322E3030206D0A2D362E30302030206C0A6F0A6E700A3231312E3230203434332E3131206D0A2D362E30302030206C0A6F0A6E700A3231312E3230203438342E3233206D0A2D362E30302030206C0A6F0A3139362E3830203331392E373720282D312E3029202E35203020393020740A3139362E3830203336302E383920282D302E3529202E35203020393020740A3139362E3830203430322E30302028302E3029202E35203020393020740A3139362E3830203434332E31312028302E3529202E35203020393020740A3139362E3830203438342E32332028312E3029202E35203020393020740A6E700A3231312E3230203331332E3230206D0A3231332E36302030206C0A30203137372E3630206C0A2D3231332E36302030206C0A30202D3137372E3630206C0A6F0A3136322E3030203235322E3030203435302E3030203534302E303020636C0A2F707320313220646566202F466F6E74312066696E64666F6E7420313220730A3020302030207267620A3331382E3030203236372E363020287829202E352030203020740A3137322E3830203430322E3030202873696E205C28785C2929202E35203020393020740A65700A2525547261696C65720A252550616765733A20310A2525454F460A>|ps>||||||>
    </output>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      \;
    </input>
  </session>>

  And now we can understand how to bring up help for these functions:

  <with|prog-language|r|prog-session|default|<\session>
    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      class(sin)
    </input>

    <\output>
      [1] "function"
    </output>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      help(plot.function)
    </input>

    <\output>
      curve \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ package:graphics
      \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ R Documentation

      \;

      Draw Function Plots

      \;

      Description:

      \;

      \ \ \ \ \ Draws a curve corresponding to the given function or
      expression

      \ \ \ \ \ (in 'x') over the interval '[from,to]'.

      \;

      Usage:

      \;

      \ \ \ \ \ curve(expr, from, to, n = 101, add = FALSE, type = "l",

      \ \ \ \ \ \ \ \ \ \ \ ylab = NULL, log = NULL, xlim = NULL, ...)

      \;

      \ \ \ \ \ ## S3 method for class 'function':

      \ \ \ \ \ plot(x, from = 0, to = 1, xlim = NULL, ...)

      \;

      Arguments:

      \;

      \ \ \ \ expr: an expression written as a function of 'x', or
      alternatively

      \ \ \ \ \ \ \ \ \ \ the name of a function which will be plotted.

      \;

      \ \ \ \ \ \ \ x: a 'vectorizing' numeric R function.

      \;

      \ from,to: the range over which the function will be plotted.

      \;

      \ \ \ \ \ \ \ n: integer; the number of x values at which to evaluate.

      \;

      \ \ \ \ \ add: logical; if 'TRUE' add to already existing plot.

      \;

      \ \ \ \ xlim: numeric of length 2; if specified, it serves as default
      for

      \ \ \ \ \ \ \ \ \ \ 'c(from, to)'.

      \;

      type, ylab, log, ...: graphical parameters can also be specified as

      \ \ \ \ \ \ \ \ \ \ arguments. 'plot.function' passes all these to
      'curve'.

      \;

      Details:

      \;

      \ \ \ \ \ The evaluation of 'expr' is at 'n' points equally spaced over
      the

      \ \ \ \ \ range '[from, to]', possibly adapted to log scale. \ The
      points

      \ \ \ \ \ determined in this way are then joined with straight lines.
      'x(t)'

      \ \ \ \ \ or 'expr' (with 'x' inside) must return a numeric of the same

      \ \ \ \ \ length as the argument 't' or 'x'.

      \;

      \ \ \ \ \ If 'add = TRUE', 'c(from,to)' default to 'xlim' which
      defaults to

      \ \ \ \ \ the current x-limits. \ Further, 'log' is taken from the
      current

      \ \ \ \ \ plot when 'add' is true.

      \;

      \ \ \ \ \ This used to be a quick hack which now seems to serve a
      useful

      \ \ \ \ \ purpose, but can give bad results for functions which are not

      \ \ \ \ \ smooth.

      \;

      \ \ \ \ \ For "expensive" 'expr'essions, you should use smarter tools.

      \;

      See Also:

      \;

      \ \ \ \ \ 'splinefun' for spline interpolation, 'lines'.

      \;

      Examples:

      \;

      \ \ \ \ \ op \<less\>- par(mfrow=c(2,2))

      \ \ \ \ \ curve(x^3-3*x, -2, 2)

      \ \ \ \ \ curve(x^2-2, add = TRUE, col = "violet")

      \;

      \ \ \ \ \ plot(cos, xlim = c(-pi,3*pi), n = 1001, col = "blue")

      \;

      \ \ \ \ \ chippy \<less\>- function(x) sin(cos(x)*exp(-x/2))

      \ \ \ \ \ curve(chippy, -8, 7, n=2001)

      \ \ \ \ \ curve(chippy, -8, -5)

      \;

      \ \ \ \ \ for(ll in c("","x","y","xy"))

      \ \ \ \ \ \ \ \ curve(log(1+x), 1,100, log=ll, sub=paste("log=
      '",ll,"'",sep=""))

      \ \ \ \ \ par(op)
    </output>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      class(z)
    </input>

    <\output>
      [1] "factor"
    </output>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      help(plot.factor)
    </input>

    <\output>
      plot.factor \ \ \ \ \ \ \ \ \ \ \ \ package:graphics
      \ \ \ \ \ \ \ \ \ \ \ \ R Documentation

      \;

      Plotting Factor Variables

      \;

      Description:

      \;

      \ \ \ \ \ This functions implements a "scatterplot" method for 'factor'

      \ \ \ \ \ arguments of the _generic_ 'plot' function. Actually,
      'boxplot' or

      \ \ \ \ \ 'barplot' are used when appropriate.

      \;

      Usage:

      \;

      \ \ \ \ \ ## S3 method for class 'factor':

      \ \ \ \ \ plot(x, y, legend.text = levels(y), ...)

      \;

      Arguments:

      \;

      \ \ \ \ \ x,y: numeric or factor. \ 'y' may be missing.

      \;

      legend.text: a vector of text used to construct a legend for the plot.

      \ \ \ \ \ \ \ \ \ \ Only used if 'y' is present and a factor.

      \;

      \ \ \ \ \ ...: Further arguments to 'plot', see also 'par'.

      \;

      See Also:

      \;

      \ \ \ \ \ 'plot.default', 'plot.formula', 'barplot', 'boxplot'.

      \;

      Examples:

      \;

      \ \ \ \ \ plot(PlantGrowth) \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #
      -\<gtr\> plot.data.frame

      \ \ \ \ \ plot(weight ~ group, data = PlantGrowth) \ \ \ \ \ \ \ \ #
      numeric vector ~ factor

      \ \ \ \ \ plot(cut(weight, 2) ~ group, data = PlantGrowth) # factor ~
      factor

      \ \ \ \ \ ## passing "..." to barplot() eventually:

      \ \ \ \ \ plot(cut(weight, 3) ~ group, data = PlantGrowth, density =
      16*(1:3),col=NULL)

      \;

      \ \ \ \ \ plot(PlantGrowth$group, axes=FALSE, main="no axes")# extremly
      silly
    </output>

    <\input|<with|color|red|\<gtr\> <with|color|black|>>>
      \;
    </input>

    \;
  </session>>
</body>

<\initial>
  <\collection>
    <associate|language|english>
    <associate|page-bot|1in>
    <associate|page-even|1in>
    <associate|page-odd|1in>
    <associate|page-right|1in>
    <associate|page-top|1in>
    <associate|page-type|letter>
    <associate|par-width|6.5in>
    <associate|sfactor|5>
  </collection>
</initial>

<\references>
  <\collection>
    <associate|auto-1|<tuple|1|?>>
    <associate|auto-2|<tuple|1.1|?>>
    <associate|auto-3|<tuple|1.2|?>>
    <associate|auto-4|<tuple|1.3|?>>
    <associate|auto-5|<tuple|1.4|?>>
    <associate|auto-6|<tuple|1.5|?>>
    <associate|auto-7|<tuple|1.6|?>>
    <associate|auto-8|<tuple|1.7|?>>
    <associate|auto-9|<tuple|1.8|?>>
    <associate|gly-1|<tuple|1|?>>
    <associate|toc-1|<tuple|<uninit>|?>>
    <associate|toc-2|<tuple|<uninit>|?>>
    <associate|toc-3|<tuple|3.|?>>
    <associate|toc-4|<tuple|3.|?>>
    <associate|toc-5|<tuple|3.|?>>
    <associate|toc-6|<tuple|3.|?>>
    <associate|toc-7|<tuple|3.|?>>
    <associate|toc-8|<tuple|3.|?>>
  </collection>
</references>

<\auxiliary>
  <\collection>
    <\associate|toc>
      <vspace*|1fn><with|font-series|<quote|bold>|math-font-series|<quote|bold>|Lecture
      4 - statistical tests> <datoms|<macro|x|<repeat|<arg|x>|<with|font-series|medium|<with|font-size|1|<space|0.2fn>.<space|0.2fn>>>>>|<htab|5mm>>
      <no-break><pageref|auto-1><vspace|0.5fn>

      <with|par-left|<quote|1.5fn>|What is a test?
      <datoms|<macro|x|<repeat|<arg|x>|<with|font-series|medium|<with|font-size|1|<space|0.2fn>.<space|0.2fn>>>>>|<htab|5mm>>
      <no-break><pageref|auto-2>>

      <with|par-left|<quote|1.5fn>|Loading Libraries (packages)
      <datoms|<macro|x|<repeat|<arg|x>|<with|font-series|medium|<with|font-size|1|<space|0.2fn>.<space|0.2fn>>>>>|<htab|5mm>>
      <no-break><pageref|auto-3>>

      <with|par-left|<quote|1.5fn>|Frequencies
      <datoms|<macro|x|<repeat|<arg|x>|<with|font-series|medium|<with|font-size|1|<space|0.2fn>.<space|0.2fn>>>>>|<htab|5mm>>
      <no-break><pageref|auto-4>>

      <with|par-left|<quote|1.5fn>|Frequency tables
      <datoms|<macro|x|<repeat|<arg|x>|<with|font-series|medium|<with|font-size|1|<space|0.2fn>.<space|0.2fn>>>>>|<htab|5mm>>
      <no-break><pageref|auto-5>>

      <with|par-left|<quote|1.5fn>|Comparing means
      <datoms|<macro|x|<repeat|<arg|x>|<with|font-series|medium|<with|font-size|1|<space|0.2fn>.<space|0.2fn>>>>>|<htab|5mm>>
      <no-break><pageref|auto-6>>

      <with|par-left|<quote|1.5fn>|A non-parametric test of means
      <datoms|<macro|x|<repeat|<arg|x>|<with|font-series|medium|<with|font-size|1|<space|0.2fn>.<space|0.2fn>>>>>|<htab|5mm>>
      <no-break><pageref|auto-7>>

      <with|par-left|<quote|1.5fn>|The Kolmogorov-Smirnov test
      <datoms|<macro|x|<repeat|<arg|x>|<with|font-series|medium|<with|font-size|1|<space|0.2fn>.<space|0.2fn>>>>>|<htab|5mm>>
      <no-break><pageref|auto-8>>

      <with|par-left|<quote|1.5fn>|Understanding magic
      <datoms|<macro|x|<repeat|<arg|x>|<with|font-series|medium|<with|font-size|1|<space|0.2fn>.<space|0.2fn>>>>>|<htab|5mm>>
      <no-break><pageref|auto-9>>
    </associate>
  </collection>
</auxiliary>
