noc21- ma35 - lec03

IIT Kanpur July 201
20 followers
1 Video View·Dec 3, 2023
[Music]
[Music]
hello friends welcome to the course
essentials of data science
with r software one in which we are
trying to
deal with the topics of probability
theory and statistical inference
so you can recall that in the last
lecture i have given you a very simple
brief introduction to the r software
that how can you install it
and how you can start working on it
when we are working on our software
then we are working directly on the r
console
in statistics or data sciences whenever
you are trying to
deal with the bigger data sets
you may require lots of programming
you may require different types of
functions
and it will be very convenient that if
you can see everything
in a single screen
in r you can work in the r console
and if you want to look into the program
you have to type the name of the program
and then you will see the content
but many times for example we are
interested in
ah looking at the different
programs side by side
because r has a facility that you can
call
of function inside a function
so to take a help or to deal with such
situation one option is that we can use
some
software
which is a link between us and our
software
but possibly it might be more helpful to
work in that
software
so there are some free software which
have been developed and
which are available which helps us
in doing different types of programming
in r
for example there is a software r studio
there is another software kin r t
i double n r
and these packages are trying to help us
well there are
some other packages also
so now my idea and my objective
in this lecture is that i want to
introduce you with
this type of supplementary software
which are trying to help us
while we are working in the r software
and i have
chosen here rstudio but surely
it should not give you a feeling that i
am trying to make an advertisement of
rstudio well i can choose anything
actually
either r studio or kenar or there are
ah some other software so please don't
think in from that point of view but ah
means i have to choose one so i have
chosen here this
r studio so in this lecture i will try
to give you a very quick
review of this r studio software that if
you are trying to work on this software
then how you are going to work and how
it is related to the r console
and how you are going to manage the four
windows of
rstudio that is the most
modest objective of this lecture
so although i believe that if you are
working in r
you must be using some similar software
so i'm not
asking you to shift from that software
but
here if you want to work in the r studio
this may help you
so let us begin our lecture so in this
lecture we are trying to we are going to
learn about that how are we going to
install the r studio software and how
are we going to work on that but
very quickly ok so now you see
so now when we are trying to use the
our software then we are basically
working on the command line
to type and execute the
basic commands there are some free
softwares like as re studio
10 r etc they are available
and they are actually working along with
the r software so this r software is
working
behind this software behind the screen
so they are essentially the interface
between
r and us and they help us in running the
r software and
the different types of command and in
case if we try to use a software then
the software
makes the coding and execution of the
programs easier
so this r studio is available at this
website
www
and actually this is also a free
software and this is written in the c
plus plus programming
language and so this is a open source
integrated development
environment for r and similarly there is
another package
t i double n r this is available from
this website you can simply go to some
search engine and just type
over there ti double n and you will get
this link very easily
now once you come to the website of
arustudio.com it will look like this
means i will try to show you it on the
website also and then you will see here
there are different types of things say
this here product
solution customers resources and
yeah there will be here download and so
on so rs studio is actually
available for different types of things
but we are interested
only here in the the r studio
part that is working for the r software
right so we have to click here download
and then it will give us the file
and then we have to save it and then we
have to simply double click on the sites
and then you have to click on the that
file and then you have to just read the
instruction and then you have to
continue by
clicking it and then it will install the
software on your
computer now
in case if you try to click on the icon
of
rstudio and open it
it will look like this what it is given
here you can see here
right there are
four windows one two three and here four
these four windows are trying to help us
in executing different types of
things and the important part is this
all those executions can be seen in a
single
screen the size of these windows can be
adjusted by
clicking on these border lines which are
here like this
which i will try to show you and
these windows will give us different
type of information
right so first let us try to see how are
you going to get this
software and then we will try to see
that how it will look like so if you
come to the
internet site and simply try to press
here rstudio.com and you try to
press it here you will get here
this type of screen this type of website
of rs studio
and if you go ahead download and then
you will see here that
you have to choose here your version
there is a
free software there is a wait software
also and there's
our studio for desktop our studio for
servers so i will simply say that in
case if you are working on the desktop
just try to click it here on the free
part which is here download
and in case if you are working on a
server then you try to click over here
on the free part and just download it
from here once you
download it from here and then you
simply double click it and and read the
condition and can try to accept it
click it again finally you will be able
to install the
software on your computer once you have
installed it and if you try to double
click on this
rstudio icon this type of window will
come
so this is the same window which i had
shown you but
in this window something is written
because i was working earlier and my
earlier commands are
visible here somewhere here where i am
trying to move my cursor
right okay so you can see here this is
my window number here one
please try to see the movement of my
cursor where
this is window number one this is here
window number two which where i am
trying to
move my cursor this is here window
number three
and this is here window number four try
to have a very clear
look so that i can explain you from the
screenshot of this window one thing i
will try to show you here
that these are here the border lines
where you are getting this
four dimensional arrow and if you try to
just
press the mouse of your computer and try
to move it here you can
increase or decrease the size of this
windows yeah
you can see here like this and like this
one right
so these are the thing which are in your
control and if you try to see here
before i try to go to my slides you can
see here what is this
where i'm trying to highlight can you
identify it what is this
don't you think that this is the same as
what you had obtained in the
r software like us here and you
started it right
so now you can understand that what is
the advantage and now
let me come back to the slides and try
to explain you
the utility of all these four windows
very quickly
right so let us try to to understand the
utility of all the windows one by one so
first i try to concentrate on the window
number one
so window number one is the place where
you try to write down
all the programs where you try to write
down all the
syntax and commands for your program and
this is called
as a script section right and then
you know that there are different
options this is the option for save
right and then there's the option for
here sir there is option for here run
so if you want to execute a particular
syntax command or program you simply
have to
highlight it and then simply try to
click here on the run
it will execute the program and if you
want to link the source of the program
you simply have to
click here on the icon of source and
similarly you can see here there are
different options here file edit code
view etc so these are very standard
thing and i don't think
the type of student to whom i am now
teaching this course
it's a very difficult thing for them
right so
means you can just miss experiment with
this window and try to see what is
there right you can make here different
types of script file
well one thing is that in our whenever
we are trying to say the script file
script file means the programming file
and that is the common
language the program or a software so
script is the
programming file in which we are trying
to write down the commands of the
r software so here in this window number
one we are trying to write those
commands now we come to our
this thing this window number here one
means i can you
can if you try to open here this here
file you will get here
our script are marked down shiny webpage
etc etc there are many many things
right so you can see here now this r is
developed and this
are marked down shiny shiny webpage etc
they are the new features well
i am not dealing with those things here
so i am not discussing it here but i
just want to show you here
right so so now i would say this simply
you simply try to
to execute it yourself now in case if
you come to the
window number here too this is called
your console
if you try to see here this is the
console that we had
discussed earlier also and this is the
place where in
our software you try to write down the
commands and programs for execution
so this is the same window which is
appearing here and
but what is happening you are not going
to
write anything over here at the command
line but what are you going to do
you are going to write here
right here in window 1
window 1 and as soon as you see here run
means execute
whatever is the execution that is
happening
in this window number two inside the r
console so now you can see whatever you
are
viewing from this window number one that
is being executed
behind the screen and whatever is being
executed behind the screen that is
visible on
window number two so that is the
advantage that you can see the script as
well as the
execution of the program simultaneously
when you are working in the
software like r studio right and
similarly if you come to the
say here window number three well i can
just show you here
before you forget that what was your
window number three
i can show you here like this right this
is your here window number three and so
on you can see here this is
environment there is a history and so on
and then
you have your import data sets and then
global environment etc etc so i am now
talking about this window over here
so this window number three gives you an
information
on different things for example whatever
variables you are going to use or define
in your program
they are available there
although they are also available in the
r console also
but here you can view them very clearly
directly on your screen and in case if
you do not
want them you can just hide them by
minimizing the
size of the screen of the window three
so that is up to you
and then here you will try to see here
there there are here different types of
option like
import data set for example if you want
to import the
data set from this mx excel or different
types of softwares possibly
this can be done for example if you try
to see here if i try to click here
import data set
import data set from csv from excel from
spss data and so on these are different
types of things are there
and you can see see here that it is
trying to give if you try to look at the
variable number here a
it is trying to give you here that cases
here are number
and it is trying to give you different
types of information and simply if you
try to come over history
it is trying to show you that what i was
exactly doing
on this software in the past so this is
trying to give you the
the details about the history right so
all those things
are available to you when you are trying
to work with our studio
and they are available very conveniently
actually
right so this is the use of window
number three
right and now in case if you come to
here window number four
the window number four is essentially
the output window
here different types of outcomes of your
graphics
they will be available different type of
information
on the packages that you want to install
or that are already installed if you
want to load a
package loader library or if you want to
take different types of help
that is also available over there for
example you can see here
the first icon here is file is when it
is here plots plot is trying to show you
the created plot that means the plots
which you have constructed
through your programming and then it is
information about the packages packages
means what are the packages that are
available
on your computer under this r software
which can be used and if some package is
not available you have to see
and that where is this and how to
install it and so on all sorts of
information about the packages available
here
then there is next option here help for
example if you
want to know some information about the
command or the syntax or how to use it
this help is going to
really extend its help to you for
example if i want to know that how to
find out the mean
and suppose i will simply try to type
here m e n
and it will give me i mean the detailed
information about the
mean function and then you have here the
finally the viewer
that means here you can view here this
different types of graphics in different
formats right so this is essentially the
fourth window which is mainly used for
for for being the output of the program
so before i try to show you let me try
to just show you that how you can
execute it
for example in case if you want to
install a package
you have learnt in the last lecture that
you have a command
install dot packages and then you have
to give the name of the package within
the double quotes inside the double
and the parenthesis and then it will
install it but
[Music]
here in case if you want to install the
package inside the rstudio
you simply have to click here at install
it will open a new window and
you simply have to type the name of the
package and then it will
and those packages will be appearing in
the drop down menu also
and then you can choose from them
directly
and in case if you want to
use a package or use a library you have
learned in the last lecture that you
have to use the command
library where you have to give the name
of the packages inside the parentheses
so here you don't have to do these
things but
what you have to do you simply have to
make a check mark like this one
in this box against the name of the
packet suppose if i want to use a
package here boot
the boot is the package which is used
for bootstrapping
right so means i will simply type here
is somewhere here say here boot and then
it will give me here the package here
boot or bootstrap
the these two packages are available i
simply come here and i try to play here
a
check mark like this as soon as i say
place this check mark inside the box the
packages
are uploaded right so in case if you try
to see
what is really happening do you really
think that just by making a
check mark in the box or if you type the
name of the package
the package can be uploaded or installed
no rstudio cannot do
this job because this because this
packages are available on the website of
the r software
but whatever you were doing inside the r
console by typing the install dot
packages or
library the same thing is executed in
at the front of this r studio very
easily you simply have to type the name
of the package and it will give you
the possible name and from where you can
choose you do not have to type
install dot packages and similarly if
you want to load a package earlier you
had to write
library and then package but now you do
not have to do those things
you simply have to make a check bar
once you make a check inside the box the
package is uploaded but
behind this thing inside the r console
what is happening it is trying to
execute the command
library so you know
that is the difference between learning
means if you don't know that
by putting a check mark or a check
inside the box what is happening in the
r console
you may not understand the basic
fundamental
that what is really happening and if
there is a problem you cannot
solve it out so that is why my objective
in this
brief lecture or in a short lecture is
simply to make you understand
that when you are working in the r
studio do not try to take it for granted
that what rstudio is doing you do not
know you you must know it
you must not ah know that what is
happening at the
back end
and this is how you have to learn it and
that is why you need to learn the
commands like install dot packages or
this
library command
right ok so let us now come back to our
slides
and now similarly if you try to go to
the help part here
which is here and if you try to for
example if i want to have some idea
about the
histogram so i can type here in this
window say hist and as soon as i type it
i will get here
this type of detail where all the
information about the command about
histogram
is available and one can
use it here and similarly if you want to
use any other command all this
information is available at your
fingertips you do not have to remember
you do not have to recall everything
and but the only thing is this you you
must have some idea about
these things right so before
i go to anything else let me try to come
back to
your here r rstudio and try to show you
here what is really happening
so now before i come to anything let me
try to first
clear this window so for cleaning the
window you know the command was here
ctrl l so i can simply use your
controller otherwise you can clear this
window by the
given commands over here now i try to
write down here
suppose i try to write down here x equal
to 1
suppose you can see here means i am
writing here
x equal to here 1 right and i will bring
the third window at the bottom
so now what you have to see as soon as i
try to highlight it
and i try to execute it here you have to
to observe what is happening here in the
window number two
and here window number three here
right so now i just highlight it and i
see here
execute as soon as i see here execute
it is trying to execute here x equal to
1
in the ra studio and you can see here
that x
equal to 1 has come here in the window
number 3. so now this is giving us an
information
that as soon as i try to put here x
equal to 1
this is being executed in the window
number here 2 well it is giving us some
means warning because this package has
been updated and so
but but i am not bothered about this
thing but definitely i am not asking you
to ignore these messages
warning messages are simply like warning
they will not stop your work but
you must know and you try to update your
software
but anyway at this stage that is not my
objective and similarly if you try to
see here suppose if i say here y is
equal to 2
and suppose if i try to define here z is
equal to x plus y
right so i am trying to write down this
all the programs over here
in this here a window number here one
and if i try to
highlight all the ah three lines and if
i try to
execute it here you can you have to see
here what is going to happen after this
x
equal to one and what is going to happen
here
in the window number two in the console
window so i now press here x equal to
here
x equal to one y equal to two and z is
equal to x plus y i
press here execute and you can see here
this has been executed here
in the window number two right and in
case if you try to
see what has happened after this window
you can see here this x equal to one y
equal to two
and z equal to y x plus y has been
executed now in case if you want to see
the value of the z
you have here two option either you try
to press here z
and try to say here execute and you can
see here the value of
z is coming out to be here three and
here you can
read the outcome z
right and if you try to see see here
also it is trying to trying to show you
that a new variable has been
executed z and whose value if you want
to see you simply have to press
enter and it will show you the value of
the zs3
and similarly if you now you come to
here this window number here four
for example if you want to see here
packages so packages
is going to give you the different
information that what are the packages
which are
mis available on my this laptop well
remember one thing that when you are
trying to install these packages these
packages
are installed only on the computer on
which you are doing it
means if you have a computer in your
office and
and say another computer at your home so
in case if you are trying to install it
on
the computer in your office it does not
mean that it is going to automatically
install
in the computer at your home right so
similarly if you want to stay here
suppose if i want to see here whether
the package
has been suppose suppose i want to see
about this call
our package and i don't know whether
this package is there or not
so i can see here see a double l and you
can see here
that as soon as i am trying to type this
name this is
appearing here and in case if i want to
install it i simply have to make here
check mark and if i want to install here
say clear package
suppose if i want to type here say
agricola
so you can see here as i that i try to
type this name over here and if i try to
see here install it will install it well
i am not doing it here
but anyway these things can be done
without any problem
and here you can see here in this file
it will try to show you the information
about the
files available in the working directory
similarly if you come to here
plots it will give you here different
types of plot in case if you are trying
to
plot it here for example if i say here
plot see here
x and y so you can see here although
there are not any observations
but it will give me here
like this there is only here one plot
here
right so and then you will means if i
want to export it
means i can save it here as image or pdf
whatever you want
and similarly if you come here on the
help and suppose if i want to get a help
on the histogram
and my command is s h i s t suppose as
soon as
start i typing here h i s you can see
here in the drop down these options are
coming and if i
choose your hist you can see here all
the information about histogram is
coming over here right and that means
you can read it and then you can
just do whatever you want right
so now ah with this brief introduction
to the r
software let me come to an end to this
lecture my objective was not really to
make you learn about the r studio
software but my objective was just to
give you a brief
introduction so that you can brush up
your knowledge you are confident
and those students who have not learnt
it earlier
this will give an idea that if they try
to learn it in the given time as soon as
possible that is not a very difficult
software
the candidate is going to help them
right so ah one thing i would like to
tell you here
and i would like to clarify here that
although i have introduced you
here with the rstudio software
but definitely in all my lectures i am
going to work only on the r console
directly on the
r software why because
in case if you work directly on the r
studio software only then it will be are
studio dependent and there is a
possibility that different people
different
student different colleagues they might
be using different types of software and
over a period of time
some new softwares may also come so my
objective here is that i would not like
to make you learn
so that you are software based these
intermediate softwares may be changing
may be improving
but ours to uh software will always
remain the same
our console will always remain the same
only the version and the improvement in
the other
software will be there so i will be
working directly on the
r console and then another advantage
will be when i am trying
to work on the r console you will also
see that how the
commands are working and how is the real
outcome
which is appearing on the r software and
how to handle with those things
so that is why ah now today onwards
after this brief introduction to the r
studio i will not come back to the r
studio software but i will be
working only on the r console
right so you ah try to have a look on
this r studio try to have a quick
revision try to understand its
utility and different types of options
which are available
and i will see you in the next lecture
till then good bye
[Music]
[Music]
[Music]
you
