Introduction to R Programming Language

Rumman Ansari   Software Engineer   2023-01-22   6413 Share
☰ Table of Contents

Table of Content:


R can be viewed as a programming language that happens to come with a large library of pre-defined functions that can be used to perform various tasks. A major focus of these pre-defined functions is statistical data analysis, and these allow R to be used purely as a toolbox for standard statistical techniques. However, some knowledge of R programming is essential to use it well at any level. For advanced users, in particular, the main appeal of R (as opposed to other data analysis software) is as a programming environment suited to data analysis.

Download R software: Click Here

Download R studio:  Click Here

Interacting with R. Unlike languages like C, Fortran, or Java, R is an interactive programming language. This means that R works interactively, using a question-and-answer model:
• Start R
• Type a command and press Enter
• R executes this command (often printing the result)
• R then waits for more input
• Type q() to exit
Here are some simple examples:



> 2 + 2
[1] 4
> exp(-2) ## exponential function
[1] 0.1353353
> log(100, base = 10)
[1] 2
> runif(10)
[1] 0.39435130 0.98811744 0.07357143 0.16689946 0.80572031 0.05292909
[7] 0.70498250 0.18781961 0.07865185 0.21618324

Don’t copy and paste the commands from this guide into R; you will find it very hard to remember the details of the language and will have to look everything up when you come to code something yourself.