Lecture 5

IIT Kanpur July 201
20 followers
1 Video View·Dec 1, 2023
Hello friends, welcome back to the course of Foundation of R-Software.
In this lecture, we are going to talk about RStudio software.
You may remember that in the last lecture, we talked a little about RStudio software.
I requested all of you to download and install RStudio software on your computer.
And try to see what it looks like, what are the options.
Today, we will talk in the same direction.
And I would like to remind you again that
RStudio software is a very good friend of RSoftware.
It helps us.
What we are working on is inside RSoftware.
But RStudio is its face.
Whatever we are doing, RSoftware is working behind RStudio software.
And I would like to clarify one more thing.
RStudio is a software.
And we have other softwares that help us work in RSoftware.
I have taken RStudio software here.
But it does not mean that I am advertising RStudio software.
Or I favor it a lot.
You can take any software.
I have no objection to it.
My objective here is that I want to show you.
What is the difference between working inside RSoftware and working in an external software?
And how do we work it?
And we hope that if we take an example of RStudio and explain it to you.
If you want to work in any other software, you will not have any such problem.
So let's start the lecture with this objective.
And we will try to learn about RStudio.
In the last lecture, I told you to go to rstudio.com.
This is our website.
And from here, you can go to the download section.
Click on this place.
You can download its free version.
And you can install it.
And when you install it on your computer.
And when you click on the RStudio icon.
You will see a window like this.
And this is the screenshot of the RStudio window.
I will show you in the screenshot.
And we will try to show you what are the options in RStudio software.
So you can see here that there are many windows.
You have divided the screen into four parts.
This is your window number one.
Suppose this is our window number two.
This is our window number three.
And this is our window number four.
So you will see that it looks like a text editor.
Where we type our commands.
And if you try to recognize window number two.
So it will look exactly the same as your R console.
And the truth is that this is R console.
And in window number three, you will see something like this.
Here it is written environment, history, etc.
So here we define our variables.
And we have used which variables first.
What were their values?
What were their properties?
You will see all this here.
Similarly, in window number four, you have many options.
Files, Plot, Packages, Help, Viewer, etc.
There will be information about them.
But now we will work.
I have just given you an overview.
Now we will show you these windows one by one.
And what are their functions?
What are their functions?
We will show you this.
But first of all, let us show you RStudio.
How will it look?
Here you will see where we are moving the cursor.
This is our window number one.
If you look below, what is this?
This is your window number two.
And if you try to recognize,
then see how it looks to you.
If you try to remember R console,
then see this was your R console.
If you look at it,
you can see this R console in RStudio.
This is your R console.
Here you will write all your programs
in this window number one.
Here I am moving my cursor.
This program and your functions and syntax
will be executed here.
This is your R console window.
Similarly, this is the third window
where I am showing my cursor.
In this window,
you will find out
what are their variables.
We will tell you about this
one by one slowly.
Similarly, you see
this is the fourth window
where our cursor is.
Here you have files, plots, packages,
help, viewer, etc.
This is our fourth window.
Now we will try to take
these windows one by one.
We will try to tell you
about different functions
of RStudio.
But,
I would like to tell you
that RStudio has
a lot of functions.
We are not going to explain
all the functions here.
Instead,
we will tell you
about the common functions
that we use frequently.
With time,
RStudio has added
a lot of functionalities.
We are not going to talk
about the advanced functions
of RStudio.
As I said earlier,
I have only one purpose
that I want to tell you
about an external software.
I want to show you
how to work
in an external software.
Whatever we do,
it is actually done
in RStudio.
Let us take a small example
and through that example,
we will try to show you
how to work in RStudio.
For example,
let us take
these three commands
library-mass,
attach-bacteria,
and fix-bacteria.
Some of these commands
are known to you
and some of them
are not.
You know that
mass is a built-in package
and to load this library,
we have to use
the command library-mass.
After that,
in this mass
package,
there is a data set
named bacteria.
This bacteria is
in this mass package.
We want to open
this mass package
and edit it.
For that,
we have to use
fix-bacteria.
First of all,
if we are working
in R console,
we have to go
to the data editor
and type these three
commands.
After that,
if we want to use
library-mass,
we have to
highlight it
and press
ctrl-r.
Now,
we will do the same
thing in R studio.
We will highlight
the command library-mass
and press
one button
named run.
So,
if we want to execute
all these commands,
we have to highlight them.
After highlighting,
we have to press ctrl-r
in R console.
We can do the same
by pressing
run command.
I will show you
these things
in R studio.
First, I will show you
through screenshot.
Here,
I have written
library-mass,
attached-bacteria,
and fix-bacteria.
First of all,
highlight the command
library-mass.
After highlighting,
we have to press
run command.
After clicking,
you will see
library-mass
in R console.
Now, try to understand
what is happening here.
You may remember
when you started working
in R console,
you used
library-mass command
to upload
your mass package.
Now, how did you do
the same thing here?
You highlighted
library-mass,
but it was easy
to do it.
You don't have to remember
ctrl-r command.
You can run
by pressing
run command.
This is
one of the
features of
R studio.
We will talk
about some other
commands later.
Now,
you have
executed
the function
of library-mass.
If you
highlight
library-mass
and press
ctrl-enter,
then
you will
execute
the function
of library-mass.
This is
similar to
R console.
Now,
we will
show you
how to do it
in R studio.
We will copy
these three
commands
to save time.
Now,
we will
highlight
library-mass
and press
ctrl-enter.
Now,
you have
to observe
that
when we
highlight
library-mass
and press
run command,
you will
see
library-mass.
This is
the same
command
we used
to upload
a package.
Now,
we have
to attach
this bacteria.
We have
to click
R function.
If you
click on
source function,
then you will
see
the values
of
bacteria data set.
Now,
if you
highlight
fixed bacteria,
you will
see
this
file.
Now,
if you
look at
window number
3,
you will
see
that
there are
6 variables
of
bacteria data set.
If you
click on
this,
you will
see
this
command.
Why
view bacteria?
Because
you have
clicked
this
command.
Now,
let's
go back
to
the
slide.
In the
slide,
I would
like to
tell you
that
how to
use
matrix in
R.
I will
tell you
in next
lecture.
Now,
we are
talking
about
R studio
functions.
You
can
use
R
studio
functions
in
R
studio.
You
can
use
R
studio
functions
in
R
studio.
You
can
use
R
studio
functions
in
R
studio.
You
can
use
R
studio
functions
in
R
studio.
You
can
use
R
studio
functions
in
R
studio.
You
can
use
R
studio
functions
in
R
studio.
You
can
use
R
studio
functions
in
R
studio.
You
can
use
R
studio
functions
in
R
studio.
You
can
use
R
studio
functions
in
R
studio.
You
can use
R
studio
functions
in
R
studio.
You
can
use
R
studio
functions
in
R
studio.
You
can
use
R
studio
functions
in
R
studio.
You
can
use
R
studio
functions
in
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
You
can
use
R
studio.
