Goal

In this project we will see the usage of select() function in R. It is a function of dplyr package. We will use the data set named Undergraduate Admission Test Survey in Bangladesh.

First we need to install the necessary packages for this project and we will also upload the data.

Upload the Data and Install Packages

library(dplyr)
library(DT)
Data <- read.csv("C:/Users/yrabb/Downloads/Undergraduate Admission Test Survey in Bangladesh.csv")

This data set has 600 observations and 15 variables.

Select Variables by Index Positions and Names

Data%>%
  select(2,3)%>%
  datatable()
Data%>%
  select((c(2,3)))%>%
  datatable()
Data%>%
  select((c('Politics','University')))%>%
  datatable()

Drop Variables and Select all Variables between Two Variables

Data%>%select(-c('Politics', 'University'))%>%
  datatable()
Data%>%select(('Politics':'University'))%>%
  datatable()

Select all Variables start and end with

Data%>% select(starts_with('f'))%>%
  datatable()
Data%>% select(ends_with('s'))%>%
  datatable()

Select Variables Containing Characters

Data%>%select(contains('f'))%>%
  datatable()
Data%>%select_if(is.numeric)%>%
  datatable()