Hello and this lecture we're going to learn how to build cumulated frequently line starts with a plot
to.
We're going to use the same database D-Mo. and we will create a cumulative frequency or line chart for
the variable income.
OK first of all let's load the package as we need it.
Ju-Ju plot package.
And then the plier package because I need the count function from this package.
OK.
Now let's create a new data frame with the unique income values and their absolute frequencies that
counts.
I will name this date or frame my data.
OK.
Now let's see the data in my data.
So here in this column income I have all the value of the variable income and in the second column Prak
I have all the absolute frequencies for these values.
Now let's compute the cumulative counts and then the cumulative percentages.
To compute the cumulated counts the variable q.
I'm going to use the term income something that they are there and I will of course the track column
of the to upgrade my data.
This one that does and to compute the cumulative percentage is I would simply divide the cumulative
columns by the number of rows of the variable Dbl.
In other words the number of cases in the data frame D-Mo. OK.
And now that adds the cumulative frequencies column to the initial my data matrix.
So to the to the metrics to the data for my data I'm going to add a new column called compare the cumulative
frequencies column that let's it.
So now for each unique value of the variable in column I have the cumulative Uralic to break and see
the cumulative percentage
OK.
Now I'm able to plot the charge that plotted mousseline line first using the finger on the line.
So here I have to define my data frame which is called My data.
And they attached it Fontan I have to indicate the of all the axes x and y.
So the income on the x axis and the cumulative percentage is variable come for on the y axis lot of
the chart and they have it you can notice it.
If you want to plot a flat line you will use the Thompson Joannes tap instead.
The options aren't exactly the same as do that.
Now here in this chart you have that stepped bely.
Now let's create a group cumulate to request line.
We will build a cumulated frequency line chart for the variable in column the same variable.
But each year but but this time story for each gender group.
So a line for the male group and another line for the female.
First of all we have to create to date our brain by gender using the brackets and based on.
So the date made it will contain only the male subjects have the date of crame female will contain only
female subjects that create and use them.
OK the male database is the one and the female database is the one female.
Now we have to do the same thing as before but this time for both data crame separately.
So now for the main data frame we get the unique in values and then compute the cumulate to a relative
or a relative frequencies.
The cumulative percentages.
OK with the same formula is exactly like before but now I have called the date of my date made and the
cumulative count and the cumulative percentages.
Q I AM AM and compared am I put here.
The latter I am from made that the right of S.
Ok and now let's add the cumulative related or the cumulative related frequencies column to the variable.
My data made it to the data.
My data made.
Excuse me.
And now let's see how this dataset and my data are made.
Looks like.
So here for each value of the income we have in that comfort and column the cumulative percentage.
Now let's do exactly the same thing for the female date of brain.
OK so we are going to create a new data frame my dates to emails which will contain the columns for
the values of the variable income and then we will compute the cumulative related frequency as well
as the cumulative counts will end and the cumulative percentages will work out with the same formula.
Last with three rows.
OK now let's add the cumulative percentages to the data frame.
My data be made with the bind function.
And now let's see the data frame my data the main again for each unique value of the income we have
the cumulate to relate to frequency.
But now of course for the female subjects on now we can get the chart because we have the cumulative
percentages for both both the lines of both groups male and female.
I didn't notice here we have to do line functions and for the first bomb story the date of frame it
might take come in on the y axis.
We have the cumulative percentages for the main subject and here I set the color for this line to read
and he in the second line function.
The date frame is my date of the main and only y axis.
I have the accumulated percentages for the female objects and I set the color here to blue so I can
visualize easily with the two lines of the same charge
that's drawn this.
Now here are charts.
We have both
cumulated frequents the lines for male and female subjects if you want a top line of course you must
play on line with jumps to the man to say what to do if you want to add oleaginous to the charge.
First of all we will create a new variable.
Well Judy you do the functions.
Ok I'll call her manual and this function will cross paths by the title of all legend.
Let's call it legend.
Same plan.
And here is the value option.
You must assign a color code to each gender group.
So for example the male group will have assigned to the red color the red code and the female group
will have assigned the blue code and you have to do that using see the concatenate function that create
the variable g d.
OK.
And now to build the histogram with a legend in the general line function as each of them you have to
add this off color equal to May or the first line of the male group.
And now the program now that the male color is rabs because I just find it here and color equal to females
for the female group because the program note now that the female caller the female code is blue here.
I I have also added the opposite side.
I want to make the lines a bit thicker.
So the site will be one point three.
The default value is 1.
And don't forget to add the allergy variable.
And with the plus before of course now let's round of this to get our charge that it is very pretty.
Just a moment.
OK.
So here's the chart with the two frequency lines with the legend that's all.
Thank you.