Posts

Showing posts from January, 2022

R-Basics: Part 3- All about Idexing

Image
  Overview Subset a vector based on properties of another vector. Use multiple logical operators to index vectors. Extract the indices of vector elements satisfying one or more logical conditions. Extract the indices of vector elements matching with another vector. Determine which elements in one vector are present in another vector. * Wrangle data tables using functions in the dplyr package. Modify a data table by adding or changing columns. Subset rows in a data table. Subset columns in a data table. Perform a series of operations using 'pipe operator'. Create data frames. Plot data in scatter plots, box plots, and histograms. Sample Q/As Indexing R provides powerful and convenient way of indexing a vector. We can use the logical operators to index a vector. If we compare a vector with a single number, R performs a test for each entry Let’s see some examples: index <- murder_rate < 0.71 #index murders$state[index] [1] "Hawaii" "Iowa"