Lecture 4

IIT Kanpur July 201
20 followers
Dec 1, 2023
Hello friends, welcome to the core foundations of our software.
And in this lecture, we are going to talk about the command line and the data editors.
Actually in this lecture and in the next lecture, we will continue with the same topic.
So first, let me give you a brief idea what are we going to do in this lecture.
First of all, introduce you with the basic terminologies, although I already have done
it in the past.
But just for the sake of completeness, I will formally introduce it.
And after that, I will try to show you that how are we going to work in the R software.
So when we are working in the R software, we have two options.
First option is that we try to work inside the R software and we do not take the help
of any other external software.
Second option is that we try to take the help of some external software.
These external softwares are like the friends of R software.
What is a friend?
It means as an individual human being, I can do everything what others can do.
But in case if I have a friend or if somebody gives me a helping hand like a friend, then
my job becomes easier.
So similarly, in the R software also, some friendly softwares have been developed which
help us working in the R software.
And there are a couple of software and these softwares remain popular for some time.
For example, in the last two decades, I have seen a couple of such softwares and at this
moment one of the popular software is R studio.
Besides, there are many other softwares.
So remember one thing, I am not trying to do a marketing of R studio, but that is one
of the software where I want to show you that if you try to take the help of some external
software, how the things are going to be helpful.
That is my sole objective.
So in this lecture, I will try to introduce you with the R software, but how to work on
the R software that I will try to discuss in the next lecture in detail.
So let us begin our lecture and we try to understand the basic functionalities of the
R software.
So now once you start the software, you know that what are you going to get.
That we already have done.
So I will try to show you here only the screen shot of the same thing which you now very
much familiar.
So when we start the R software, then we get here this type of window that we had called
as RGUI window that is R Graphic User Interface window and in this place here, you can see
a sign which is like a greater than sign and this is actually the prompt sign and after
this there is here a vertical line.
Vertical line is actually this is a sort of cursor.
It will give you the position where you have to type.
So this line actually this is called as command line and we try to type our command, syntax,
functions, whatever you want, we always type at this place.
So this is called command line.
And then now as we are quite familiar with the R software, we know that the execution
of the commands in the R software is not really 100% menu driven.
Some commands are there because in the RGUI window you have some file, packages etc.
But not all.
So it is not like clicking over buttons and then getting the outcome but we need to type
the commands.
So in R when you are trying to work, then both the options are there that you can type
your commands in single line or in multi lines, both are possible.
So as long as you are working on one line function, one line syntax, there is no issue.
But when you are trying to work on a command which takes more than one line, then instead
of typing it on the R console directly, it is a better option that you try to use a text
editor.
The advantage is that in case if you are trying to type the multi line program inside the
R console and if you make any mistake at any line, the R software will exit and then you
will have to type everything afresh.
Whereas when you are trying to type your command inside a text editor and then you are trying
to execute it from there, so in case if you have made a typographical mistake in typing
the commands, you will have an option to go back to your editor and make the correction
and then come back to the R software for the execution.
So that is why a couple of text editors are possible and I will try to show you here two
options.
So the first option that how you can use the built-in editor which is built-in inside the
R software and second is through some external softwares.
So the built-in editor in the R software can be accessed from this R GUI menu bar.
I will try to show you on the R console also.
So in this case, you simply have to click on file and then you have to click on the
new script.
What does this mean?
I will show you first here with the help of a screenshot and then I will show you on the
R console also.
So as soon as you begin the R software, you will have here this type of R GUI window.
Then you can come here on the file and then you can see here new script.
Now as soon as you click on the new script, a new window will open here and where you
can type the commands.
And from this window also you can execute them in a particular way, I will try to show
you and you can also save this window, means you can save it as a script file.
So if you try to see here, I am trying to use here a new terminology script.
Script is something like program, means in most of the languages, for example, if you
are using C language, Fortran, etc., anything, you always try to write down the program and
that is called here as a script.
So at this moment, as soon as you click on the new script file, it will open a sort of
new file whose name will be untitled R editor.
And then you can type your command inside this file, you can edit it and then in case
if you want to execute a function or a command from this file, then you have both the options.
Both the options means, in case if you want to execute only one line, that also you can
do.
In case if you want to do more than one line or the entire program, you can also do it
in a single step.
For that what you have to do, that suppose you want to execute a particular line, for
that you simply have to highlight it.
Means in order to highlight it, either you can use your mouse or you can bring your cursor
to that point and then using the shift key and arrow key, you can highlight it.
And once you highlight it, you have to press control R.
That means there is a key on your keyboard, CTRL, that is called as control key and you
have to choose the key of the R alphabet and you have to press control and R together.
As soon as you try to do it and the execution will be happening on the R console.
Now in case if you want to execute more than one lines also, that is also possible.
Same process, you simply try to highlight those group of lines which you want to execute
and just press control R and the execution will be done on the RGUI window on the command
line.
So let me try to show you this on the R console and then I will try to show you that how other
options can be worked upon.
For example, if you try to see here, this is the RGUI window, I try to come here file
and then I come here with the new script.
I can show you here, I can make the size of this window is small, so that you can see
all the things together.
You can see here with these operations, I am trying to show you that it is possible
to manage these different windows in the R software also.
So you can see here, this is your here untitled R editor.
Now suppose I try to make here very simple commands, although I have not told you the
command but I believe that if I take very simple thing, you will understand them very
easily.
Suppose if I try to take here say x equal to 2 and then next line y is equal to 3 and
then I try to say here z is equal to x plus y.
Well, these are very simple operations which you understand.
So now suppose I want to execute x, so I will just highlight it either using my mouse or
using the shift key and arrow key and now I am pressing here control and R together.
So I will press here control and then R and then you have to observe what really happens
in the R console.
So I will say here control R. Now you can see here some operation has been done on the
R console window.
Now if you try to see here what is the value of here x on the R console, you will see this
is here x.
Then similarly if you try to highlight here y equal to 3 and then you press here control
R, y equal to 3 is executed on the R console and you can see here this is y is coming out
to be here 3.
Now if you try to and then I try to highlight here z is equal to x plus y and I press here
control R and you can see here now this here is z like this and if you try to see here
the value of here z is coming out to be 5.
Well ok now I have shown you these operation line by line.
I try to now show you that how I can execute them in the group.
So I clear this screen and just for the sake of understanding I try to change this value.
I make it x equal to 20, y equal to 30 and now I highlight all the 3 lines together and
I press here control R.
So you can see here that all these operations have been done and if you want to see what
are the values of x, y and z, so you can also do from here this window I will type here
the values of x, y and z and I press here control R.
You can see here x equal to 20, y equal to 30 and z is equal to 50.
So this is how you can make such operations.
Now in case if you come back to your this slide then I would like to introduce you here
that this is the way by which I have shown you that the execution of the commands can
be done on the R software.
Other option is that we can use some other external editor software which help us in
running of the R commands.
So actually different editors are available and most of them are actually free.
So for example, one editor is R studio and then another editor is tinRTINR.
So earlier long time back when I was learning this R at that time tinR was very popular
nowadays R studio is very popular.
So they are the free software.
So I would like to just give you an idea that how this software work and sometime when you
are working in the software either R studio, tinR or any other software the working become
fast and more efficient that is the only thing.
But please remember the calculation and the analysis inside the R software when you are
trying to do in the R studio or tinR that is still being done inside the R software
only but R studio and tinR will give you only a phase something like the phase is there
but R software is behind the screen.
So we are going to understand here a brief functioning through the R studio software
but my objective here is to teach you the R software and I would not like you to be
dependent on any particular type of such software.
So I will try to give you an idea but then after that I will come back to the R console
only and I will be executing all the commands only inside the R console only.
So that is what you have to keep in mind.
So in case if you want to download the tinR software you can go to this website and then
you can download it this is a free software.
Similarly if you want to have the R studio software then you can go to this website www.rstudio.com
and this software is written in the C++ programming language and it is a free and open source
integrated development environment for R. So well when you try to go to the website
of R studio they have some version which are paid and some version which are free.
So I am talking here only of the free version.
So if you go to the website of www.rstudio.com so I have given you here a screen shot then
you can see here there is a download section here you just try to click here click on that
download and after the download you will come to this such a home page where you can see
here one of the option here is R studio desktop free and others are there are different other
versions so they are paid but I am not talking of that.
You simply try to download this R studio desktop for free and then you just click on this one
you will get a file over this you simply try to click on the file install it on your computer
and if you double click on the icon of the R studio software you will get a screen like
this one.
So this will have here four screens one two and here three and here four screen and they
have their different types of functionalities.
So anyway I am not going to take you further I am not going to discuss about the utilities
of these different four windows and but I would stop here and then in the next turn
I will try to show you that how you can work on the R studio software.
So my starting point in the next lecture will be this slide where I will be talking about
the different types of functionalities with respect to this four windows.
So now I will stop here but then my request to you will be at least you try to install
this R studio software on your computer and try to play with it try to have a look what
is really happening in that software and how the windows are there how do they look like.
So that will help me when I am trying to explain you about these intricacies in the next lecture
then at least you will be familiar with the face of the R studio.
And then I will try to give you a brief overview only well in case if I try to take up the
R studio also possibly it will take a very long time to explain you all the functionalities
of the R studio.
So my objective is only to give you an idea that how these secondary softwares are going
to help us in the working of the R software.
So you try to download this software and try to see how you can work in the RGUI window
also with the text editor and I will see you in the next lecture till then goodbye.
