R Programming

Good Essays
Topics: Ring
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

    Likelihood Programming in R Marco R. Steenbergen Department of Political Science University of North Carolina, Chapel Hill January 2006 Contents 1 Introduction 2 Syntactic Structure 2.1 Declaring the Log-Likelihood Function . . . . . . . . . . . . . . . . . . . . . . . 2.2 Optimizing the Log-Likelihood . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Output 4 Obtaining Standard Errors 5 Test Statistics and Output Control 2 2 2 4 5 5 7 1 1 Introduction The programming language…

    • 363 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    programming

    • 21645 Words
    • 157 Pages

    NETWORK PROGRAMMING BIT 4206 BIT 4206 Network Programming Course Outline Prerequisites: BIT 3102 Network Management BIT 3201 Object Oriented Programming Objectives: • By the end of the course the learner should be able to: Have knowledge about Unix Technologies (IPC, POSIX threads, Unix file system) • Be able to develop client-server network applications on the internet, based on UNIX/linux Course Outline An overview of C++ Inheritance, Polymorphism, Encapsulation, Templates, Dynamic…

    • 21645 Words
    • 157 Pages
    Powerful Essays
  • Good Essays

    Programming

    • 3434 Words
    • 14 Pages

    Keyboard shortcuts Keyboard shortcuts are combinations of two or more keys that, when pressed, can be used to perform a task that would typically require a mouse or other pointing device. Keyboard shortcuts can make it easier to interact with your computer, saving you time and effort as you work with Windows and other programs. Most programs also provide accelerator keys that can make it easier to work with menus and other commands. Check the menus of programs for accelerator keys. If a letter…

    • 3434 Words
    • 14 Pages
    Good Essays
  • Good Essays

    Programming

    • 2845 Words
    • 12 Pages

    1 C PROGRAMMING NOTE Based on the syllabus of Final B.Sc. Mathematics (Calicut University) By T K Rajan Selection Grade Lecturer in Mathematics Govt. Victoria College, Palakkad Phone: 9446537545 2 Contents 1 2 3 4 5 6 7 8 9 10 11 Introduction C Fundamentals Operators and Expressions Data Input Output Control Statements Functions Arrays Program structure Pointers Structures and Unions Datafiles 3 11 17 21 25 32 35 42 44 47 53 3 INTRODUCTION Computer Basically it is a fast calculating…

    • 2845 Words
    • 12 Pages
    Good Essays
  • Good Essays

    Programming

    • 3038 Words
    • 13 Pages

    Programming Programming Logic and Design, 6th Edition Chapter 3 Exercises 1. In Figure 3-10 the process of buying and planting flowers in the spring was shown using the same structures as the generic example in Figure 3-9. Describe some other process with which you are familiar using exactly the same logic. Answer: Student answers will vary widely. They should come up with processes that fit the generic logic shown in Figure 3-9. Some examples could include: making a dentist appointment…

    • 3038 Words
    • 13 Pages
    Good Essays
  • Good Essays

    Programming

    • 684 Words
    • 3 Pages

    stations can choose their own programming under Section 326 - Communications Act - gives broadcasters freedom from censorship. American Radio has ‘format freedom’ Task - provide attractive programming to meet informational and entertainment needs of audience Matrix of Radio Programming Local Programming - original programming produced by radio station Prerecorded or Syndicated Programming - obtained from a commercial supplier outside the station Network Programming - obtained from radio nets…

    • 684 Words
    • 3 Pages
    Good Essays
  • Powerful Essays

    A Survey of Literature on the Teaching of Introductory Programming Arnold Pears, Stephen Seidman, Uppsala Uni., Sweden Uni. of Central Arkansas, USA Arnold.Pears@it.uu.se sseidman@uca.edu Lauri Malmi, Linda Mannila Elizabeth Adams Helsinki Uni. of Tech., Finland Åbo Akademi Uni., Finland James Madison Uni., USA lma@hut.fi Linda.Mannila@abo.fi adamses@jmu.edu Jens Bennedsen Marie Devlin James Paterson IT Uni. West, Denmark Newcastle Uni., UK…

    • 16837 Words
    • 70 Pages
    Powerful Essays
  • Good Essays

    Programming

    • 1575 Words
    • 7 Pages

    Lab Exercises MS1.2 Data Structures and Algorithms Using C++ Lab – 1 (2 Hrs Real Time) 1.1 Write a C + + program to display any message. 1.2 Sum of digit 1.2.1 Reverse the number 1.2.2 Factorial of a number 1.2.3 Fibonacci series 1.2.4 Armstrong number checking 1.2.5 Prime no checking 1.2.6 Palindrome Checking 1.2.7 Odd or even number. 1.2.8 Perfect number checking. Lab – 2 (2 Hrs Real Time) 2.1 2.2 2.3 2.4 2.5 Write a program to calculate the following: Find Maximum of N numbers. Find Minimum…

    • 1575 Words
    • 7 Pages
    Good Essays
  • Satisfactory Essays

    Programming

    • 586 Words
    • 3 Pages

    1 Like · C omment · Share · 4 hours ago v ia mobile · Gna Gna Che a ng shared The Search f or people, places and things Library of Lov e 11 people like this. (ប ល័ េស យ )'s photo. Spons oreKhm e r A ngk or d Lay Socheat a Write a comment. . . March 7 v ia mobile Lit t le Fa s hion មនុ ៧ ក◌់ វ ន ស ត ញ់ ប់ ក់ អង្ េល អី ស ឲ គុ យេ ប់ មួ លិ ព ន http:// យ ខិ ត www. khmerload. com/ Code: 0094 Lay Socheat a shared a photo. ws/11779 Sey ne Price 1= $19.00 ម នុ ៧…

    • 586 Words
    • 3 Pages
    Satisfactory Essays
  • Powerful Essays

    Linear Programming

    • 15778 Words
    • 64 Pages

    Linear Programming 4 In the preceding chapter on sensitivity analysis, we saw that the shadow-price interpretation of the optimal simplex multipliers is a very useful concept. First, these shadow prices give us directly the marginal worth of an additional unit of any of the resources. Second, when an activity is ‘‘priced out’’ using these shadow prices, the opportunity cost of allocating resources to that activity relative to other activities is determined. Duality in linear programming is essentially…

    • 15778 Words
    • 64 Pages
    Powerful Essays