Presentation describing the subset function in R
Ashu Guru
Author
03/13/2019
Added
203
Plays
Description
Presentation describing the subset function in R
Searchable Transcript
Toggle between list and paragraph view.
- [00:00:00.560]Many times we want to extract a set of rows from a table which fulfill a certain
- [00:00:07.040]filtering criteria and we will use a function in R which is called a subset to
- [00:00:13.360]do that.
- [00:00:14.800]So we see that we have a table which has a column filter on attribute 1,
- [00:00:20.334]attribute 2 and a set of rows which are separated by commas.
- [00:00:25.440]Now what we want is we want to select a few rows based on a filtering criteria.
- [00:00:30.360]What the filtering criteria for this particular example is that I want every
- [00:00:36.746]row in which the column filter on value is greater than equal to 100.
- [00:00:42.551]2 and less than equal to 10.3.
- [00:00:45.320]So my output should look something like this.
- [00:00:48.240]So the data is stored in a file and 1st row is column names and then we have set
- [00:00:56.139]of data.
- [00:00:57.800]I will first set the working directory to the folder where I have the text file.
- [00:01:03.360]To do that I use the command set WD.
- [00:01:05.960]I am running that instruction.
- [00:01:08.160]Next I am going to read the table from the text file.
- [00:01:13.400]The text file has a header and there is a separator which is, for the data.
- [00:01:20.800]So I am going to run that instruction and then I will apply the function subset.
- [00:01:28.960]So subset takes the input table and then we give the command subset on the value
- [00:01:38.802]of filter on column of the table data where it is greater than equal to 2 and
- [00:01:48.281]the same columns value is less than equal to 100.3.
- [00:01:56.880]So I run this instruction and then print the output and that's what we were
- [00:02:01.616]expecting.
The screen size you are trying to search captions on is too small!
You can always jump over to MediaHub and check it out there.
Log in to post comments
Embed
Copy the following code into your page
HTML
<div style="padding-top: 56.25%; overflow: hidden; position:relative; -webkit-box-flex: 1; flex-grow: 1;"> <iframe style="bottom: 0; left: 0; position: absolute; right: 0; top: 0; border: 0; height: 100%; width: 100%;" src="https://mediahub.unl.edu/media/10778?format=iframe&autoplay=0" title="Video Player: Presentation describing the subset function in R" allowfullscreen ></iframe> </div>
Comments
0 Comments