00:01
Today we're going to look at some r packages.
00:03
We're going to use the arrange function, the filter function, these select function, the mutate function, and the summarize function.
00:32
And they're all functions within the d -pliar package.
00:39
So we're going to load that up and show you how this works.
00:41
So let's go ahead and tackle this.
00:42
So let's get r studio going.
00:45
And i made some data to play around with today.
00:49
So in order to install the package, you need to do install.
00:53
Packages.
00:54
And then you put quotes around the package.
00:57
I've already done it.
00:58
And to run it, you press this little run button.
01:01
Like i said, i've already done it.
01:02
So i need to do it.
01:03
And then once you install it, you need to actually blow it into your r sessions.
01:09
You have to do library de -plyer, run it.
01:12
Now we're good to go.
01:12
And let's first do a range.
01:16
So what a range does is it reorders the rows of a data frame based on one more variable.
01:22
So it's like a sorting function.
01:26
So for example, here's some data that i made, name, age, and then numbed cats.
01:32
So let's run that.
01:34
And if you look at the data frame, there it is, alice, bob, charlie, david, their ages, and the number of cats.
01:39
So we can do sort it, df, and then this little print percent greater than percent that is a pipe operator.
01:50
It takes the df and then it's the object that a range is using the data from.
01:58
What you're going to do is take pump an age into it, so you're going to sort it by age.
02:03
You run this.
02:05
And you can do, if you don't put descending, d .e.
02:10
S -c and then the variable it's going to go ascending.
02:15
Let's run that and here we see in both.
02:18
So here's the sorted age from least to greatest.
02:22
Here's sorted descending, grace to least.
02:27
All right, so is that.
02:28
Now filter, what we're going to do is it selects a subset of rows based on specified conditions.
02:42
So what you're going to do, we're going to sort, or excuse me, filter the data from d .s.
02:46
For people who are older than 25.
02:50
So df, pipe operator, filter when age is greater than 25.
02:55
So we run that.
02:56
Let's take a look at the data.
02:58
There it is.
02:58
So it's only bob and david.
02:59
Their ages are greater than 25.
03:01
But if you want to make it equal to you, just put greater than equal to 25.
03:04
And you can see we've captured alice as well because she is 25.
03:08
All right, so filter.
03:11
Now we're going to do select.
03:12
And select is used to choose specific columns from the data frame.
03:20
So for our data frame, which has name, age, and numcats, we're just going to do name and numcats...