R is a open source programming language and environment (RStudio) for statistical computing and data visualization.
Now, if you are planning to learn data science or already familiar with python programming then you may have question why should I learn r-programming, when we can do all type of data analysis using python.
Yes, both are powerful programming language, depending on requirement we have to decide which programming language is best fit for our business requirement, r-programming is used for statistical analysis, and python is used for large-scale application development, though both programming languages are open source and supported by large communities, difference is in the approach to data science.
Yes, r-programming is going to be one of the most demanding skill for data science, which will impact future digital business world! R is a open source programming language supported by huge communities and continuously improving libraries and tools.
R-programming is mainly used for statistical computing and scientific calculation; but in time of digital transformation many organization using r for various type of advanced analytical report, specially healthcare, medical and financial institutes.
R-programming is being used by many big companies like Microsoft, Google, Twitter etc, Microsoft introduced r-studio, if you want to be a data scientist, then with python you should also learn r-programming.
If you don't have any programming experience, then you should learn python first, because r is comparatively hard to learn, though that’s not mandatory, but will be helpful.
First download R for your operating system Here is the link Install R for Windows, you also can find the link on Google , While installing the R ext, make sure you ran that as administrator on your machine
Once you have installed R on your machine, then Download R Studio select the free version for your operating system.
Now, let's get familiar with basic r programming syntax, like writing variable, assigning value, if else conditional statement, loop etc.
There is no command to create a variable in r programming, the moment you assign a value using <-
sign, the variable is created
site <- "WebTrainingRoom"
In r programming <- is assignment operator, so in above example "site" is the name of the variable and "WebTrainingRoom" is the value.
a1 <- 'single quote value a1' print(a1) b1 <- "double quotes value b1" print(b1)
To assign value we use <-
sign, to print the value print(variable-name).
here we learn the syntax of for loop in r programming.
for (i in 5:14) { print(x) }
Above statement will print the value of variable i, till the value become 15.
In following example, we learn how to write if-else condition using different operators in r programming.
x <- 100 y <- 80 if (x> y) { print("x is greater than y") } else if (x == y) { print ("x and y are equal") }
As you can see, we have two variable, x and y, comparing if value is greater and value is equal. comparison operators are same as other programming languages.
Now we see how to write a function in r programming, function with parameters.
functionName1 <- function(arg_1, arg_2, ...) { function body }
In above example “functionName1” is the name of variable where the returned value will be captured. this syntax may look something similar to array function in JavaScript.