# Introduction to indexing in R

**indexing in r** This is a topic that many people are looking for.

**thevoltreport.com**is a channel providing useful information about learning, life, digital marketing and online courses …. it will help you have an overview and solid multi-faceted knowledge . Today,

**thevoltreport.com**would like to introduce to you

**Introduction to indexing in R**. Following along are instructions in the video below:

lets talk about extraction for vectors and matrices and our suppose Ive got some vector V that just has some numeric content down here we can see the V is numeric and then weve got five elements in V if I want to extract specific elements in V Im going to use the square bracket notation so lets say I want the first element I could type in v square bracket and then tell our what elements you want these inputs have to be integers right because it was just a first second third and so on position so if I want this first

element I can type in V extract one and I get five point five out you can also put in vector arguments so if I want to first through the fourth elements I get type in v1 through 4 and I get the first through the fourth elements out of V for matrices its fairly similar Im going to create a matrix that just has the numbers one through twelve for rows and three columns if I want to extract some specific elements from this matrix Im again going to use the square bracket notation but notice here that weve got a square bracket

one through four well we had four rows then a comma one through three we had three columns so this first argument is going to indicate what row or rows you want the second argument is what column or columns you want lets try to get the second row second column element out of map type in these square brackets second row thats the first argument and then what column do I want I want the second column and that gives me six if we want to extract an entire row or an entire column you can leave one of these arguments out so

lets just take the third column Im not going to type in any specific row because I wanted to give me all the rows and then I can tell it what column I want third column all rows we get nine through 12 now we can use these extract functions along with relational operators for instance if I wanted to get all the elements out of V that were greater than one I could type in V and then subset it or extract something from it and what I want to extract is all of the elements in V that are greater than one

and that gives me five point five and two point three so think for a second about what this is actually doing in our if I type in V greater than one what that really gives me is a logical result so its true if thats true and its false otherwise so you can type in a bunch of truths or falses here for each element or just give it a logical result that has the same length as this vector and you can extract things fairly easily based on some criteria like whether its greater than or less than or equal to some number

tags:

rstats, R(programming language)

Thank you for watching all the articles on the topic **Introduction to indexing in R**. All shares of thevoltreport.com are very good. We hope you are satisfied with the article. For any questions, please leave a comment below. Hopefully you guys support our website even more.