“Hello World” R Program | Beginning R Programming – Part 1

Learn how to write your first r program, the classic ‘Hello, World’ print statement. You’ll learn 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. Part of the pre-bootcamp coursework during our data science bootcamp, this introduction to R programming video series will get you up to speed on R, programming 101, and programming foundations.

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’s 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 see getting started video
in the R section of this installing R on Windows, OSX, and Linux
So your first program you ever write in any programming language is your classic
“hello world” print statement here So we’re basically going to create a
variable name and assign or store string values so 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
So let’s start this basic “hello world”
program from scratch so 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 kind a controlled editor window
any output after running our code will appear in the other window here
So 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 backwards 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 output 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 so 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

Prerequisites:
Download the Data Set
How to Install R

Part 2: 
Data Types

Full Series:
Beginning R Programming

More Data Science Material:
[Video] R Programming for Excel Users
[Blog] R vs Python: Which is better for data science?
[Blog] An Introduction to Learn R Programming

(707)

Rebecca Merrett
About The Author
- 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.

Avatar

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>