Example: quiz answers

R Programming - Tutorialspoint

R Programming i About the Tutorial R is a Programming language and software environment for statistical analysis, graphics representation and reporting. R was created by Ross Ihaka and Robert Gentleman at the University of Auckland, New Zealand, and is currently developed by the R Development Core Team. R is freely available under the GNU General Public License, and pre-compiled binary versions are provided for various operating systems like linux , Windows and Mac. This Programming language was named R, based on the first letter of first name of the two R authors (Robert Gentleman and Ross Ihaka), and partly a play on the name of the Bell Labs Language S.

R Programming 13 Linux Installation R is available as a binary for many versions of Linux at the location R Binaries. The instruction to install Linux varies from flavor to flavor. These steps are mentioned under each type of Linux version in the mentioned link. However, if you are in a hurry, then you can use yum command to install R as follows:

Tags:

  Linux, Programming, Tutorialspoint, R programming

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Transcription of R Programming - Tutorialspoint

1 R Programming i About the Tutorial R is a Programming language and software environment for statistical analysis, graphics representation and reporting. R was created by Ross Ihaka and Robert Gentleman at the University of Auckland, New Zealand, and is currently developed by the R Development Core Team. R is freely available under the GNU General Public License, and pre-compiled binary versions are provided for various operating systems like linux , Windows and Mac. This Programming language was named R, based on the first letter of first name of the two R authors (Robert Gentleman and Ross Ihaka), and partly a play on the name of the Bell Labs Language S.

2 Audience This tutorial is designed for software programmers, statisticians and data miners who are looking forward for developing statistical software using R Programming . If you are trying to understand the R Programming language as a beginner, this tutorial will give you enough understanding on almost all the concepts of the language from where you can take yourself to higher levels of expertise. Prerequisites Before proceeding with this tutorial, you should have a basic understanding of Computer Programming terminologies. A basic understanding of any of the Programming languages will help you in understanding the R Programming concepts and move fast on the learning track.

3 Copyright & Disclaimer Copyright 2016 by Tutorials Point (I) Pvt. Ltd. All the content and graphics published in this e-book are the property of Tutorials Point (I) Pvt. Ltd. The user of this e-book is prohibited to reuse, retain, copy, distribute or republish any contents or a part of contents of this e-book in any manner without written consent of the publisher. We strive to update the contents of our website and tutorials as timely and as precisely as possible, however, the contents may contain inaccuracies or errors. Tutorials Point (I) Pvt. Ltd. provides no guarantee regarding the accuracy, timeliness or completeness of our website or its contents including this tutorial.

4 If you discover any errors on our website or in this tutorial, please notify us at R Programming ii Table of Contents About the Tutorial .. i Audience .. i Prerequisites .. i Copyright & Disclaimer .. i Table of Contents .. ii 1. R OVERVIEW .. 1 Evolution of R .. 1 Features of R .. 1 2. R ENVIRONMENT SETUP .. 3 Try it Option Online .. 3 Local Environment 3 3. R BASIC SYNTAX .. 5 R Command Prompt .. 5 R Script File .. 5 Comments .. 6 4. R DATA TYPES .. 7 Vectors .. 8 Lists .. 9 Matrices .. 9 10 Factors .. 10 Data Frames .. 11 5. R VARIABLES .. 12 Variable Assignment .. 12 R Programming iii Data Type of a Variable.

5 13 Finding Variables .. 13 Deleting Variables .. 14 6. R OPERATORS .. 16 Types of Operators .. 16 Arithmetic Operators .. 16 Relational Operators .. 18 Logical Operators .. 19 Assignment 21 Miscellaneous Operators .. 22 7. R DECISION MAKING .. 24 R - If Statement .. 25 R Statement .. 26 The Statement .. 27 R Switch Statement .. 28 8. R LOOPS .. 30 R - Repeat Loop .. 31 R - While Loop .. 32 R For Loop .. 33 Loop Control 34 R Break 35 R Next Statement .. 36 9. R FUNCTION .. 38 Function Definition .. 38 Function Components .. 38 Built-in Function .. 38 R Programming iv User-defined Function .. 39 Calling a Function.

6 39 Lazy Evaluation of Function .. 41 10. R STRINGS .. 43 Rules Applied in String Construction .. 43 String Manipulation .. 44 11. R VECTORS .. 49 Vector Creation .. 49 Accessing Vector Elements .. 51 Vector Manipulation .. 51 12. R LISTS .. 54 Creating a List .. 54 Naming List Elements .. 55 Accessing List Elements .. 55 Manipulating List Elements .. 56 Merging Lists .. 57 Converting List to Vector .. 58 13. R MATRICES .. 60 Accessing Elements of a Matrix .. 61 Matrix Computations .. 62 14. R ARRAYS .. 65 Naming Columns and Rows .. 66 Accessing Array Elements .. 66 Manipulating Array Elements .. 67 Calculations Across Array Elements.

7 68 R Programming v 15. R FACTORS .. 70 Factors in Data Frame .. 70 Changing the Order of Levels .. 71 Generating Factor Levels .. 72 16. R DATA FRAMES .. 73 Extract Data from Data Frame .. 75 Expand Data Frame .. 76 17. R 79 18. R DATA RESHAPING .. 82 Joining Columns and Rows in a Data Frame .. 82 Merging Data Frames .. 84 Melting and Casting .. 85 Melt the Data .. 86 Cast the Molten Data .. 87 19. R CSV FILES .. 89 Getting and Setting the Working Directory .. 89 Input as CSV File .. 89 Reading a CSV File .. 90 Analyzing the CSV File .. 90 Writing into a CSV File .. 93 20. R EXCEL FILE .. 94 Install xlsx Package.

8 94 Verify and Load the "xlsx" Package .. 94 Input as xlsx File .. 94 Reading the Excel File .. 95 R Programming vi 21. R BINARY FILES .. 96 Writing the Binary File .. 96 Reading the Binary File .. 97 22. R XML FILES .. 99 Input Data .. 99 Reading XML File .. 101 Details of the First Node .. 103 XML to Data Frame .. 105 23. R JSON FILE .. 106 Install rjson Package .. 106 Input Data .. 106 Read the JSON File .. 106 Convert JSON to a Data Frame .. 107 24. R WEB DATA .. 109 25. R DATABASES .. 111 RMySQL Package .. 111 Connecting R to MySql .. 111 Querying the Tables .. 112 Query with Filter Clause .. 112 Updating Rows in the Tables.

9 113 Inserting Data into the Tables .. 113 Creating Tables in MySql .. 113 Dropping Tables in MySql .. 113 26. R PIE CHARTS .. 115 Pie Chart Title and Colors .. 116 R Programming vii Slice Percentages and Chart Legend .. 117 3D Pie Chart .. 118 27. R BAR CHARTS .. 120 Bar Chart Labels, Title and Colors .. 121 Group Bar Chart and Stacked Bar Chart .. 122 28. R BOXPLOTS .. 124 Creating the Boxplot .. 125 Boxplot with Notch .. 126 29. R HISTOGRAMS .. 127 Range of X and Y values .. 128 30. R LINE GRAPHS .. 130 Line Chart Title, Color and Labels .. 131 Multiple Lines in a Line Chart .. 132 31. R SCATTERPLOTS .. 134 Creating the Scatterplot.

10 135 Scatterplot Matrices .. 136 32. R MEAN, MEDIAN & MODE .. 138 Mean .. 138 Applying Trim Option .. 139 Applying NA Option .. 139 Median .. 140 Mode .. 140 33. R LINEAR REGRESSION .. 142 Steps to Establish a Regression .. 142 lm() Function .. 143 R Programming viii predict() Function .. 144 34. R MULTIPLE REGRESSION .. 147 lm() Function .. 147 Example .. 147 35. R LOGISTIC REGRESSION .. 150 Create Regression Model .. 151 36. R NORMAL DISTRIBUTION .. 153 dnorm() .. 153 pnorm() .. 154 qnorm() .. 155 rnorm().. 156 37. R BINOMIAL DISTRIBUTION .. 158 dbinom() .. 158 pbinom() .. 159 qbinom() .. 159 rbinom() .. 160 38.


Related search queries