R Programming - PowerPoint PPT Presentation

1 / 41
About This Presentation
Title:

R Programming

Description:

You will most likely click on 'Windows (95 or. later)'. Click on 'base' ... R is freeware! When you run R ... The prompt. where you. can enter. commands. ... – PowerPoint PPT presentation

Number of Views:29
Avg rating:3.0/5.0
Slides: 42
Provided by: mickey9
Category:

less

Transcript and Presenter's Notes

Title: R Programming


1
R Programming
2
  • R can be downloaded at the following link
  • http//cran.r-project.org/
  • You will most likely click on Windows (95 or
  • later).
  • Click on base.
  • Save the file R-2.4.1-win32.exe. This is about
    a 20 megabyte file.

3
Background
  • R is a system for statistical analysis and
    graphics.
  • R was heavily influenced by 2 languages S and
    Scheme
  • R is freeware!

4
When you run R
The prompt where you can enter commands.
5
Creating Variables
  • Variable names must start with a letter. They
  • may contain numbers, periods. They cannot
  • contain ,?,underscore, etc.

6
Creating a vector or array
7
Manipulating Arrays
8
(No Transcript)
9
Descriptive Statistics
10
help.search
  • Suppose I wonder if theres a way to find the
  • interquartile range (IQR). I may not be sure
  • about the command to get that.

11
help
  • Now that I know what the function is called, I
  • can read more about the documentation.

12
Sampling
13
Random Number Generation
14
Cumulative Probability
15
Quantiles (aka Percentiles)
16
Density
  • Caution! For continuous
  • distributions, this is
  • not a probability but the
  • height of the pdf. For
  • discrete distributions, this
  • is a probability.

17
Chi-Square? Exponential?
  • There are many other distributions as well. You
    have
  • to search the documentation to find the base
    word.
  • But you will probably have r? p? q? d? for
    finding
  • various aspects about the distribution. Also be
  • careful that you understand what parameters you
  • need to give it.

18
Histograms
19
(No Transcript)
20
Boxplots
21
Also
  • We can also create
  • pie charts (use the function pie)
  • bar charts (use the function barplot)
  • stem and leaf plots (use the function stem)
  • To the best of my knowledge, I dont think that
  • there is a way to make a dotplot.

22
Scatterplots
23
(No Transcript)
24
Matrices
25
(No Transcript)
26
(No Transcript)
27
(No Transcript)
28
(No Transcript)
29
(No Transcript)
30
Running R from a file
  • Obviously if we have a number of operations
  • we want to run, it would not be best to type
  • them individually from the command prompt.
  • We could make a mistake and would then have
  • to retype them.

31
  • To run a program from a file, place all
  • commands that you would normally run from
  • the command prompt in a text file. Name the
  • file with a .r extention.

32
From the file menu
Select Source R code
33
  • Find the .r file that contains your code and
  • then select open.
  • Your code will be compiled.

34
Comments
  • In the file that contains your code, you may
  • want to place comments.
  • To do so, place a in front of what you want
  • commented out.

35
Creating Functions
  • Example

36
Notice that inside the vector y was created
inside the function and then outside the
function it reverts back to what it was before.
37
Reading data from a file
  • datafile.dat

38
(No Transcript)
39
Lists
  • Lists can contain various
  • amounts and type of
  • information.

40
(No Transcript)
41
Additional Functions
  • Regression lm or lsfit
  • t-test t.test one and two sample tests.
  • test for proportions binom.test and also
    prop.test - These will do both one and two
    sample tests and find confidence intervals.
  • chi-square test for independence chisq.test
Write a Comment
User Comments (0)
About PowerShow.com