temp<-100
if(temp>50){
  print('temp is high')
}else{
  print('low')
}
## [1] "temp is high"
iq<-50
if(iq<100){
  print('average')
}else if(iq>100){

  print('better')
    
  }else{
    print('bad')
  }
## [1] "average"
height<-5.9
if(height>5){
  print('tall')
}else if(height>5.5){
  print('too tall')
}else if(height<5){
     print('short')
  }else{
     print('too short')
   }
## [1] "tall"

if else condition

money<-100000
if(money!=0){
  print('party in taj')
}else if(money<50000){
  print('party in daspalla')
}else if(money<=1000){
  print('party in food courts')
}else{
  print('sad party')
}
## [1] "party in taj"

for loop

``{r} x<-c(1:20) for(x in 1:20) print(x)

```

for(l in 1:5)
for(j in 1:4)
print(paste("step",l,j))
## [1] "step 1 1"
## [1] "step 1 2"
## [1] "step 1 3"
## [1] "step 1 4"
## [1] "step 2 1"
## [1] "step 2 2"
## [1] "step 2 3"
## [1] "step 2 4"
## [1] "step 3 1"
## [1] "step 3 2"
## [1] "step 3 3"
## [1] "step 3 4"
## [1] "step 4 1"
## [1] "step 4 2"
## [1] "step 4 3"
## [1] "step 4 4"
## [1] "step 5 1"
## [1] "step 5 2"
## [1] "step 5 3"
## [1] "step 5 4"
for(f in 1:2){
for(p in 1:10){
if(p<=5)
  print(paste(f,"step",5))
  else
  print(paste(f,"step",10))
 }
}
## [1] "1 step 5"
## [1] "1 step 5"
## [1] "1 step 5"
## [1] "1 step 5"
## [1] "1 step 5"
## [1] "1 step 10"
## [1] "1 step 10"
## [1] "1 step 10"
## [1] "1 step 10"
## [1] "1 step 10"
## [1] "2 step 5"
## [1] "2 step 5"
## [1] "2 step 5"
## [1] "2 step 5"
## [1] "2 step 5"
## [1] "2 step 10"
## [1] "2 step 10"
## [1] "2 step 10"
## [1] "2 step 10"
## [1] "2 step 10"
c<-data.frame(a=c(1:10),b=c(20,30))
c
##     a  b
## 1   1 20
## 2   2 30
## 3   3 20
## 4   4 30
## 5   5 20
## 6   6 30
## 7   7 20
## 8   8 30
## 9   9 20
## 10 10 30
for(i in 1:nrow(c)){
if(c[i,"a"]<5){
 a<-1
}else
 a<-0
 
if(c[i,"b"]==20){
 b<-1
 }else
b<-0
  print(paste(a,b))
  }
## [1] "1 1"
## [1] "1 0"
## [1] "1 1"
## [1] "1 0"
## [1] "0 1"
## [1] "0 0"
## [1] "0 1"
## [1] "0 0"
## [1] "0 1"
## [1] "0 0"
a<-data.frame(color=c("blue","red","orange"),names=c("leela","navya","shyama"))
a
##    color  names
## 1   blue  leela
## 2    red  navya
## 3 orange shyama
leela<-function(a,b){
c<-a*b
return(c)
}
leela(10,20)
## [1] 200
leela<-function(a,b){
c<-a*b+a+b
return(c)
}
leela(40,17)
## [1] 737
leela<-function(b=10,a=20){
  for(i in 1:a){
    for(k in 5:b){
    print(paste(i,"step",j))
    }
  }
}
leela()
## [1] "1 step 4"
## [1] "1 step 4"
## [1] "1 step 4"
## [1] "1 step 4"
## [1] "1 step 4"
## [1] "1 step 4"
## [1] "2 step 4"
## [1] "2 step 4"
## [1] "2 step 4"
## [1] "2 step 4"
## [1] "2 step 4"
## [1] "2 step 4"
## [1] "3 step 4"
## [1] "3 step 4"
## [1] "3 step 4"
## [1] "3 step 4"
## [1] "3 step 4"
## [1] "3 step 4"
## [1] "4 step 4"
## [1] "4 step 4"
## [1] "4 step 4"
## [1] "4 step 4"
## [1] "4 step 4"
## [1] "4 step 4"
## [1] "5 step 4"
## [1] "5 step 4"
## [1] "5 step 4"
## [1] "5 step 4"
## [1] "5 step 4"
## [1] "5 step 4"
## [1] "6 step 4"
## [1] "6 step 4"
## [1] "6 step 4"
## [1] "6 step 4"
## [1] "6 step 4"
## [1] "6 step 4"
## [1] "7 step 4"
## [1] "7 step 4"
## [1] "7 step 4"
## [1] "7 step 4"
## [1] "7 step 4"
## [1] "7 step 4"
## [1] "8 step 4"
## [1] "8 step 4"
## [1] "8 step 4"
## [1] "8 step 4"
## [1] "8 step 4"
## [1] "8 step 4"
## [1] "9 step 4"
## [1] "9 step 4"
## [1] "9 step 4"
## [1] "9 step 4"
## [1] "9 step 4"
## [1] "9 step 4"
## [1] "10 step 4"
## [1] "10 step 4"
## [1] "10 step 4"
## [1] "10 step 4"
## [1] "10 step 4"
## [1] "10 step 4"
## [1] "11 step 4"
## [1] "11 step 4"
## [1] "11 step 4"
## [1] "11 step 4"
## [1] "11 step 4"
## [1] "11 step 4"
## [1] "12 step 4"
## [1] "12 step 4"
## [1] "12 step 4"
## [1] "12 step 4"
## [1] "12 step 4"
## [1] "12 step 4"
## [1] "13 step 4"
## [1] "13 step 4"
## [1] "13 step 4"
## [1] "13 step 4"
## [1] "13 step 4"
## [1] "13 step 4"
## [1] "14 step 4"
## [1] "14 step 4"
## [1] "14 step 4"
## [1] "14 step 4"
## [1] "14 step 4"
## [1] "14 step 4"
## [1] "15 step 4"
## [1] "15 step 4"
## [1] "15 step 4"
## [1] "15 step 4"
## [1] "15 step 4"
## [1] "15 step 4"
## [1] "16 step 4"
## [1] "16 step 4"
## [1] "16 step 4"
## [1] "16 step 4"
## [1] "16 step 4"
## [1] "16 step 4"
## [1] "17 step 4"
## [1] "17 step 4"
## [1] "17 step 4"
## [1] "17 step 4"
## [1] "17 step 4"
## [1] "17 step 4"
## [1] "18 step 4"
## [1] "18 step 4"
## [1] "18 step 4"
## [1] "18 step 4"
## [1] "18 step 4"
## [1] "18 step 4"
## [1] "19 step 4"
## [1] "19 step 4"
## [1] "19 step 4"
## [1] "19 step 4"
## [1] "19 step 4"
## [1] "19 step 4"
## [1] "20 step 4"
## [1] "20 step 4"
## [1] "20 step 4"
## [1] "20 step 4"
## [1] "20 step 4"
## [1] "20 step 4"
leela<-function(a,b){
a<-10
b<-20
return(a*b)
}
leela()
## [1] 200