SQL Server 2016 supports running R code in SQL Server using stored procedures. This feature created a new way to query the data in SQL Server. Microsoft introduced this feature under R Services. With Python support in SQL Server 2017, Microsoft changed the package name from R Services to Machine Learning package. To be able use or explore this functionality, you need to know R.
I am going show you the basics of R language in this post. Please check my older blog about how to setup R Services/Machine Learning in SQL Server side and client side to learn about the setup process. You don't need to install anything today to learn the basics of R. We will worry about querying SQL data later. I am going to use R-Fiddle for demos, It's free and you don't need to install anything.
R Expressions
Let's start with variables, to store data in a variable you need to use <-
As you can see, you don't need to specify a type for a variable, I just give a name without type to call it later. Also just like JavaScript you can re-assign any value to any variable at any time. You can use T as a shorthand for TRUE and F as a shorthand for FALSE.
R Functions
Nothing is new here, To call a function, you need to type its name, followed by one or more arguments to that function in parenthesis. Here is some basic functions.
rep() function a value multiple times.To get help about any function you can call help(function_name), To get an example of a usage a function you can call example(function_name).
To repeat a value, you can use rep function.R Vectors
Vectors are list of values. R uses vectors for many of its operations and graphs. Vector's values can be any type as long as they are all the same type! Here are some samples for creating array of values by using c function. c is short for Combine.
If you need a sequence of numbers, you can create it with start:end notation. Here is an example using : notation to create a vector.
You can do the same thing with seq() function. Seq() function allows you to change increments.
We can use the index number of a vector to access an individual value in a vector. Unlike many languages R's vector indices start with 1. To get the first value of a vector, you need to pass 1 rather than 0. You can insert/edit vector values by using start:end notation too.
We can do all kind of calculations with vectors, Here is some examples. Since R is an analytic language, It doesn't surprise me to have this kind of functionality.
R Fiddle is a great tool and location to practice R, Visual R Tools is a great Visual Studio addition if you like to use Visual Studio. Extension is available in Community version, so you don't need to have full paid version to practice and learn R. I will continue to write about R in my next posts.

To be honest as a trainer it is very informative and helpful article. You are doing amazing job indeed. We are also doing same for the IT education. For more about us plz visit Learn R Programming
ReplyDeletenice article,Thanks for your information.
ReplyDeleteiOS Application Development Training in Ameerpet, Hyderabad
It's amazing blog And useful for me Thanks
ReplyDeleteIt's Very nice , Thanks for sharing
iOS App Development Online Training
Nice information thank you so much
ReplyDeleteR Programming Training in Hyderabad
thank you for the information. visit us at
ReplyDeleteR Programming Training in Austin
ReplyDeleteAmazing article. Your blog helped me to improve myself in many ways thanks for sharing this kind of wonderful informative blogs in live. I have bookmarked more article from this website. Such a nice blog you are providing ! Kindly Visit Us big data training in Velachery | Hadoop Training in Chennai | big data Hadoop training and certification in Chennai | Big data course fees
Your post is really awesome. Your blog is really helpful for me to develop my skills in a right way. Thanks for sharing this unique information with us.Data Science Online Training
ReplyDeleteThank you for giving great information. R Language training in Mumbai
ReplyDeleteThanks for such a great article here. I was searching for something like this for quite a long time and at last, I’ve found it on your blog. It was definitely interesting for me to read about their market situation nowadays.
ReplyDeletePython Training in Noida
Nice, it was definitely interesting for me to read about their market situation nowadays.
ReplyDeleteAWS Training in Delhi
Thanks for sharing such a great article here
ReplyDeleteNetworking Training in Gurgaon
Its a wonderful post and very helpful, thanks for all this information. You are including better information.
ReplyDeleteIOS APP Development Training in Noida
IOS APP Development Course in Noida
IOS APP Development Training institute in Noida
Nice and good article. It is very useful for me to learn and understand easily. Thanks for sharing your valuable information.
ReplyDeletePython Training in Noida
Thank you for your post. This is superb information.
ReplyDeleteNetworking Training in Gurgaon
Networking Training institute in Gurgaon
ReplyDeleteUseful Information, your blog is sharing unique information....
Thanks for sharing!!!
Mobile application training in hyd
Best iphone training in hyderabad
Iphone apps training in hyderabad
It was really a nice post and I was really impressed by reading this keep updating
ReplyDeleteNice work, your blog is concept-oriented, kindly share more blogs like this
Tableau Training
Android App development Course
Data Science course
Dot net Course
Ios Development Course Online
Informatica Training
Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
ReplyDeleteData Science with R Programming training in Electronic City
Nice post. thanks for sharing it. Get the best data science training institute in Gurgaon, Noida, Delhi NCR.
ReplyDeleteIt's a Nice post! Thank you for sharing your knowledge to others, it was very informative and in depth one.
ReplyDeleteR Training in Electronic City
Thanks for such useful information with clear content.Your information will help how how to use R,from beginner basics to advanced techniques from R Programming Training Institute in Bangalore
ReplyDeleteabinitio online training
ReplyDeletespark online training
scala online training
azure devops online training
app v online training
sccm online training
windows admin online training
R Programming Course in Noida
ReplyDeleteGreat post! It's really helpful to see the basics of R language explained clearly, especially for those who are new to data analysis and machine learning. It's also good to know that there are free tools like R-Fiddle available for learning and practicing. As a .Net developer in Delhi,I can see the potential for incorporating R and machine learning into our projects, and I appreciate the guidance on how to set it up in SQL Server. Thanks for sharing!
ReplyDelete