Skip to main content
Assessment and Research at Office of Minority Affairs and Diversity

Gene’s R Examples (SIMPLE via Rstudio IDE)

The following examples are one of many data query options via RStudio:

First, you will want to download the dplyr package. 

Then type: 

Then give your object a name, in this case “applejack”: 

>applejack  <- Actual name of your data table.

If you want to see all the names of the variables/column headings, you have the option to type the following: 

>names (applejack)

Now give your object another name to query the column heading/variables you want to select:

applejack1<-select(applejack, variable1, variable2, variable3, variabl4, variable 5…….)


applejack1<-select(applejack, variable1:variable19)

>applejack2 <- filter (applejack1, Variable2==’Y’,variable5  > 3.5 )


Now you will see your queried data in upper right hand corner of your RStudio. 


Another option is to utilize the  dplyr  pipe function: 

>applejack %>% select(variable1, variable2, variable3, variabl4, variable5…….) %>% filter (Variable2==’Y’,variable5  > 3.5)



>applejack %>% select(variable1:variable5…….) %>% filter (Variable2==’Y’,variable5  > 3.5)



If you want to arrange your selected/generated data frame in certain order and want to see up to 20 rows information you are about to generate, you can use the following command: 

 > applejack %>% arrange(variable1)%>%print(n=20)