Preview

R Programming

Good Essays
Open Document
Open Document
17324 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
R Programming
R for Programmers
Norman Matloff University of California, Davis c 2007-8, N. Matloff December 4, 2008

IMPORTANT NOTICE: This document is no longer being maintained. My book on R programming, The Art of R Programming, is due out in August 2011. You are welcome to use an early draft at http://heather.cs.ucdavis.edu/˜matloff/132/NSPpart.pdf; it was about 50% complete and contains bugs, but should be useful. Licensing: This work, dated December 4, 2008, is licensed under a Creative Commons Attribution-No Derivative Works 3.0 United States License. Subsequent works by the author that make use of part or all of this material will not be covered by the license. Copyright is retained by N. Matloff in all non-U.S. jurisdictions.

1

Contents
Prerequisites 1 What Is R? 2 Why Use R for Your Statistical Work? 3 How to Run R 3.1 3.2 10 11 11 12

Interactive Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 Running R in Batch Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 13 16 16

4 A First R Example Session (5 Minutes) 5 Functions: a Short Programming Example 6 Scalars, Vectors, Arrays and Matrices 6.1 6.2 6.3 6.4 6.5 6.6 6.7

“Declarations” . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 Generating Useful Vectors with “:”, seq() and rep() . . . . . . . . . . . . . . . . . . . . . . 17 Vector Arithmetic and Logical Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 Recycling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 Vector Indexing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Vector Element Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 6.7.1 6.7.2 6.7.3 General Operations . . . . . . . . . . . . . . . . . . . . .

You May Also Find These Documents Helpful

  • Satisfactory Essays

    7. In Table 5, two r values are reported as r = –0.498 and r = –0.528. Describe each r value in words, indicating which would be more statistically significant, and provide a rationale for your answer.…

    • 617 Words
    • 3 Pages
    Satisfactory Essays
  • Good Essays

    6.03 chemistry

    • 736 Words
    • 5 Pages

    Insert a complete data table, including appropriate significant figures and units, in the space below. Also include any observations you made over the course of Part II.…

    • 736 Words
    • 5 Pages
    Good Essays
  • Satisfactory Essays

    Dillard lab2

    • 517 Words
    • 4 Pages

    Answer the questions and report your data in this fillable PDF using the observations and results you…

    • 517 Words
    • 4 Pages
    Satisfactory Essays
  • Better Essays

    Introduction to SAS. UCLA: Statistical Consulting Group (2007). Retrieved on December 1, 2013 from http://www.ats.ucla.edu/stat/sas/notes2/…

    • 1093 Words
    • 5 Pages
    Better Essays
  • Satisfactory Essays

    This discussion requires you to use the web-based statistical software that we will be using in this course: Stat-Crunch.…

    • 343 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Chromotography Lab

    • 3574 Words
    • 15 Pages

    Note: Please post this assignment to your dropbox. THE DROPBOX IS ANAGALOGOUS TO AN E-MAIL ACCOUNT. (To accomplish your assignment, you may cut&paste the observations section of the assignment into your text editor (such as Microsoft Word). Complete your answers - then send the answers as an attachment to the dropbox. Attachment examples include Word document, Excel graph, etc.) Your dropbox can be entered via the dropbox tab at the top of the screen. Make sure you title your assignments properly. You do not need to show your calculations. Edit the observations sheet to present the data in a clear fashion. USE CAPITAL LETTERS FOR THE TEXT/DATA YOU ENTER IN YOUR REPORT.…

    • 3574 Words
    • 15 Pages
    Good Essays
  • Satisfactory Essays

    heredity lab worksheet

    • 540 Words
    • 3 Pages

    Part 1: Using the lab animation, fill in the following data table to help you generate your hypothesis, outcomes, and analysis:…

    • 540 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Yes Man

    • 405 Words
    • 2 Pages

    The purpose of this experiment is to review simple mathematical and graphing techniques. In Part A mostly “mathematical treatments of data” will be reviewed as well as a basic review of graphing. Part B will expand on more elaborate graphing techniques.…

    • 405 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Scavenger Hunt Essay

    • 1592 Words
    • 7 Pages

    Sample at least fifteen people and record their data in a simple table or chart; study the examples from Section 12-3.…

    • 1592 Words
    • 7 Pages
    Good Essays
  • Better Essays

    M & M Project Paper

    • 1203 Words
    • 5 Pages

    This paper will discuss the methods taught in Statistics this past semesters using what is being referred to as the M&M® project. Methods include random sampling, calculating random proportions, mean, standard deviations, creating histograms and identifying their shape such as bell, constructing confidence intervals for proportions and hypothesis testing of the samples. Each section of the M&M® project will demonstrate a lesson that was learned by applying the knowledge from the class to each separate part of the M&M project itself. The paper will conclude by discussing reasons why the results of the samples may have been different than anticipated.…

    • 1203 Words
    • 5 Pages
    Better Essays
  • Best Essays

    Time to Practice Week 1

    • 1891 Words
    • 12 Pages

    2. Compute the means for the following set of scores saved as Ch. 2 Data Set 3 using IBM® SPSS® software. Print out a copy of the output. (Please refer to attachment)…

    • 1891 Words
    • 12 Pages
    Best Essays
  • Satisfactory Essays

    why not!

    • 471 Words
    • 2 Pages

    Insert a complete data table, including appropriate significant figures and units, in the space below. Also include any observations you made over the course of Part II.…

    • 471 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    Psychology Timeline

    • 2125 Words
    • 9 Pages

    This activity introduces you to the basic statistics that researchers use to summarize their sets of data.…

    • 2125 Words
    • 9 Pages
    Powerful Essays
  • Powerful Essays

    Ringworm

    • 1190 Words
    • 5 Pages

    Course Description: This course is designed to give students the basic skills to organize and summarize data, as well as an introduction to the fundamental principles and application of statistical inference. The course emphasizes an understanding of statistical concepts, and interpretation of descriptive statistics along with application of basic (bivariate) analysis methods (e.g., t-test, chi square, ANOVA).…

    • 1190 Words
    • 5 Pages
    Powerful Essays
  • Good Essays

    Adf-Realtes

    • 2143 Words
    • 18 Pages

    Topics Distribution of the sample mean. Central Limit Theorem. Confidence intervals for a population mean. Confidence intervals for a population proportion. Sample size for a given confidence level and margin of error (proportions). Poll articles. Hypotheses tests for a mean, and differences in means (independent and paired samples). Sample size and power of a test. Type I and Type II errors. You will be given a table of normal probabilities. You may wish to be familiar with the follow formulae and their application.…

    • 2143 Words
    • 18 Pages
    Good Essays

Related Topics