Hello at the beginning of course we are going to learn how to filter author lacked our data because
there are many situations when we want to filter out some cases before running our statistical procedures.
For example when we are interested only in the results on a certain group of the whole population for
example only the women or other respondents over 40 in the first lesson will see how to filter the data
in base are using brackets for example I'm going to use a theory this file called democratic theory.
The it contains information demographic information about a group of car owners a population of car
owners.
I'm going to create a new data frame team or based on this find using the red dot and the function.
So let's get started.
Let you.
Our date of frame.
So our data frame contains information like age marital status marriage or our marriage income education.
That's a categorical very variable with five or six categories car drivers car category which is also
a categorical variable with three categories standard economy and luxury gender with two categories
of worth.
Female and male.
And whether the subject is retired or not with two categories now.
And yes
ok.
Each time we operate the filtering procedure or a new date of Graeme D-Mo. 2 will be created.
Let's say how to use one filter.
Both cost lateral that only the female object format from our data frame.
So we're going to create a new data frame D-Mo. to from the initial variable Deeble the filtering condition
is put here in the bracket.
So the variable gender must be equal to be made.
You'll notice that here we have a double equal because it's the condition of equality.
Opt for the filtering condition we have to put a comma and then nothing after the comma.
This is important.
This way we tell the program that we want to retain all the variables all the columns of the initial
data brain so that we want to filter the cases the top just by gender but we want all the columns for
the variables.
Let's do it now on troll Cantor and let's see our new barrel of our new data frame excuse me D-Mo. to
you can notice here in the column gender all the objects in the new data crave are made so that the
male subjects were excluded were removed from the data frame we requested.
Now let's retain the object with the income greater than 100.
So let's make the filtering using a continuous variable.
Again the filtering condition is put in the bracket.
So the variable income must be greater than one hundred again up to the present condition we put a comma
and then nothing without that.
And now let's take the variable excuse me the new data frame.
There is more to
do here in the income column we have here only the income higher than one hundred.
If you're roll down here all is that subject with with income over 100 were retained.
Now if you only want to keep some variables some column for example you want to keep only the variable
1 3 and 5 on the dead man's age income and gender.
Want to read Babylon.
OK.
The filtering condition is the same so the income must be higher than 100.
But after the coma you put the concatenates the Stefansson.
And here is the fact that you put the variable you want to keep 1 3 and that.
OK.
That's Ron.
Let's look now at the data D-Mo. to all of the variable age income and gender worry change and all the
income Archiv pools greater than one hundred Aufforderung condition requested.
What to do if you want to drop some variables.
For example you want to drop the variable 6 7 and 8 that man card category gender and retired
the filtering condition is the same.
The income is greater than 100.
And after the coma you put again the theme for.
But with the negative in front of it meaning you want to drop the variables 6 7 and 8.
So you put in the fact that this is six column H.
Let's see what happens.
Kontrol counter and let's do our new date frame Cointreau answer.
Again not only the variable age marital income education and car price.
What were retained the other variables were removed and of course again all the income on this column
are greater than one hundred.
Now let say how to use two or more fields are bearable.
There's a sample that the board you want to collect on the female object with income over one hundred.
So here in the brackets you have to put two conditions to filtering conditions separated by the amber
count.
So the gender must be equal to the female and the income must be higher than 100.
That's run it.
And let's you the date rape again.
OK.
Here is the column the gender is female in all the data Crame.
And here in the income column all the values are greater than 100.
That's all these laxer.
Thank you.