R exercise 2

Short exercise for R. Write a script "Rex02.R" for the following task:

  1. Make a variable "x.vec", which is a sequence of integers ranging from 0~10
  2. Make a variable "y.vec", which is x.vec plus 15
  3. Produce summaries of "x.vec" and "y.vec", and identify their means.
  4. Make a data frame "all.points" by combining "x.vec" and "y.vec".
  5. Make a subset "three.points" by assigning your selection of any three records within "all.points". Do it by indexing on "all.points".
  6. Name each column in "three.points" as "xx" and "yy", respectively.
  7. Produce a scatterplot for "three.points", where the x axis is for elements in "xx" and the y axis is for elements in "yy".
  8. Add a line to the plot with intercept = first element in y.vec and slope = 1
    Tip: check help for summary(), names(), plot() and abline().

Show me your scripts and final plot!

Updated by Xue Li 9/10/2013