This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
library(dslabs)
#Data frame
bs5th<-data.frame(name=c("ali","ahmad","sania","sara","adil","sharjeel","subhan","arbaz","asad","hassan","waleed")
,cgpa=c(2.5,3.2,3.9,2.99,3.10,2.99,2.91,2.87,3.2,3.52,2.50)
,grade=c("D","B","A","C","B","A","B","B","B","A","D"))
#for knowing class
class(bs5th)
## [1] "data.frame"
#which have gpa greater then 3
ind<-bs5th$cgpa>3
bs5th$name[ind]
## [1] "ahmad" "sania" "adil" "asad" "hassan"
#which have grade equal to A
def<-bs5th$grade=="A"
bs5th$name[def]
## [1] "sania" "sharjeel" "hassan"
#which have gpa greater then 3 and having grade A
bs5th$name[ind&def]
## [1] "sania" "hassan"
#which have gpa greater then 3 or having grade A
bs5th$name[ind|def]
## [1] "ahmad" "sania" "adil" "sharjeel" "asad" "hassan"
#which opertaor
which(ind)
## [1] 2 3 5 9 10
#match operator
match(c("ali","ahmad"),bs5th$cgpa)
## [1] NA NA
#in and in operator
c("ali") %in% bs5th$name
## [1] TRUE
Note that the echo = FALSE parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.