Course Description

    We'll discuss how to write your first r program, the classic ‘Hello, World’ print statement. How to create a variable name, assign or store a string value to that variable, and use the print function to print out the variable. This Beginning R programming video series will get you up to speed on R, programming 101, and programming foundations.

    This tutorial is part of the pre-bootcamp coursework for our Data Science Bootcamp.

    What You'll Learn

      >  To write your first R program



     

    If you haven’t installed R and Rstudio already, you can watch "Getting started with Python and R for Data Science" video to get started.

    For the dataset used in this exercise, download from here.



     

    Hi there! Welcome to this Data Science Dojo video series on learning R and basic programming for data science.

    This introduction to R video series will not only get you up to speed in R but also programming 101 or programming foundations. It is intended for people with little to no background in programming or any experience in programming so it’s a gentle and efficient way to get you up to speed. Once you know how to make these commands in R, you’re pretty much set to follow along the Bootcamp without much struggle in the coding side of things.

    So, if you haven’t done so already, install R and Rstudio. You can go to our tutorials site just to see the getting started video in the R section of this installing R on Windows, OSX, and Linux.

    Your first program you ever write in any programming language is your classic “hello world” print statement here. We’re basically going to create a variable name and assign or store string values - the words “hello world” to that variable - and use the print function to print out the variable to what we just stored inside that variable.

    We will explain assigning variables inputs into functions what a string data type is and what is a variable further on in the series but this is just to give you an idea of the core concepts of R programming that you’ll learn throughout the series. Let’s start this basic “hello world” program from scratch.

    To easily edit our code we’re going to open up a new R script file here and a panel will pop up for us to start writing our code. We can also directly write our code in this window here sometimes. It’s just easier to write code in a kinda controlled editor window. Any output, after running our code, will appear in the other window here.

    We’ll store “hello world” inside a variable. So, let’s give our variable a name and call this hello string. Now, we need to store a string or tie that string to a variable so we’ll use this operator to tie it to a variable and what we want to tie to that variable is the string of characters “hello world”. In programming, sometimes we read things backward so there’s a data value here that we tie or assign to a variable here.

    We’ll cover variables in more detail later on in the series. Now, we want to print our variables so we’ll use the print function for this and inside this function, we feed it what we want to print which is our variable that stores the string “hello world”. All right, so let’s run these lines of code.

    If you just place your cursor either at the end or the beginning of the line or you can highlight it as well we’ll just hit this run button here. Okay, great. It’s successfully outputs the string “hello world”. We have just coded our first program that prints “hello world”. In R, this is even more efficient because we don’t even have to reuse the print function for this. We can just use the variable name “hello string” and it will print the output string. I’ll show you what I mean here. If we type “hello world” or “hello string” we hit run we’ll see it successfully also printed “hello world”.

    In the next video, we’ll cover our main atomic datatypes.



     

     

    Rebecca Merrett - Rebecca holds a bachelor’s degree of information and media from the University of Technology Sydney and a post graduate diploma in mathematics and statistics from the University of Southern Queensland. She has a background in technical writing for games dev and has written for tech publications.