Hello Everyone, I am [INAUDIBLE] Sarikov.
In this video lecture we will learn how to use concatenation operator in R.
We will learn how to find 5 number summary of a data set in R.
And learn how to find sample mean and sample standard deviation of a data set.
Here I have R up and running, and this is basically our R command shell.
One thing we can do is basically clear up the console, our console here.
If I say clear out, and then I have whole R console cleaned.
Now I can start entering my commands.
Let me just mention now, that in R,
if you start with number sign it means that we are commenting here.
So we are commenting and it just ignores that command.
So in this lecture we're going to first start using concatenation operator for
entering data set in R.
So how do we do that?
Let's say I have the following data set.
I have a data set, which basically
contains 5 numbers, 35,
8, 10, 23, and 42.
Now how can we enter this data set to our variable in R?
First, you have to define the name of the variable.
We try to be as descriptive as possible when we define our variables.
Let's see, we see data.1.
So these are in data.1, so this are data.1.
And we use concatenation operator, and it starts with C.
And we have to enter our numbers in here using comma in between.
So we can say 35, 8, 10, 23, and 42.
And once we do that, then we store our data
set into a data.1, data.1 variable.
See, if i just write data.1, it will show me this part numbers,
in that data set and the 1 is just index of the first guy here.
Or I can just say print(data.1) and then I will get the same data set.
So this is how we use concatenation.
By the way, we can use our
fourth arrow key in our keyboard to go to previous commands.
So if I go back to data.1, the concatenation operator, if I, for example,
increase spaces in between these numbers, let's see what happens.
If I just go back and look at the date, print data.1.
Well, nothing has changed, so, basically when you have spaces
in between when you use concatenation, it ignores spaces.
But if I just go back and, for example, forget about this comma here.
So I have 35, 8, 10, 23, but I have forgot the comma here.
And come back, well, then this is all unexpected numeric.
There is an unexpected numeric constant.
And it doesn't understand 23 or 42, so we cannot do that.
So this is how we use concatenation operator.
Now that we have our data sets, we then go back and try to fix that with comma.
Okay, now that we have our data set,
which is data.1, we can do something statistics on it.
For example, we can find 5 number summary of this data set.
So how do we do this, we can just say summary and
so every time we put a function in r, we have to have a parenthesis.
And then argument goes into that function, argument here is a data set for
that function.
If I do that and push Enter, it gives me 5 number summary.
Well, in fact it gives me 6 numbers but it includes a mean here as well.
So the usual 5 number summary is the mean of data set,
first quartile, median, third quartile and the maximum of the data set.
But here I also have the mean of the data set, all right.
But if you want to just find a mean of this data set directly,
and the command and function is the mean.
And the argument again is the data.1,
because we want to find sample mean of our data set and this is what we get.
Let me mention now that the definition of the sample mean is the basically
sum of these numbers in this data set over number of points in the data set.
For example, if I just do the sum of data.1,
then I will actually get the sum of all these numbers.
And if I divide that by 5, which means I should get sample average, sample mean,
which is the same number, okay.
And then one last thing I would like to mention,
is the standard deviation, actually sample standard deviation.
If you watch, you'll find sample standard deviation,
we use a command sd for standard deviation.
People data.1, and we find our standard deviation.
So what have you learned in this lecture?
You have learned how to enter a data set in R using the concatenation operator.
You learned how to find 5 number summary of a data set in
R using a summary function.
And also you have learned how to find sample mean and sample standard deviation
of a data set in R using this functions called mean and standard deviation.