varx<-TRUE
vary<-FALSE
print(!vary)
print(varx&vary)
print(varx|vary)
isTRUE(vary)
vara<-5
if(vara>4)
{
print(varx)
}else
{
print(vary)
}
#fro loop
p<- LETTERS[1:27]
for(i in p)
{
print(i)
}
#while loop
values <- c("while loop")
count <- 5
while(count <7){
print(values)
count = count + 1
}
#repeat loop
n <- c("hello world")
count <- 2
repeat {
print(n)
count <- count+1
if(count > 7)
{
break
}
}
#create to vectors of different lengths.
vector1 <- c(6,2,1)
vector2 <- c(10,16,22,43,15,25)
#vectors as input to arrays.
result <- array(c(vector1,vector2),dim = c(3,3,2))
print(result[1,1,1])
print(result[3,3,1])
#manupulate arrays.
mat1 <- result[2,2,1]
print(mat1)
mat2 <- result[3,3,1]
print(mat2)
print(mat1+mat2)
# defining a function.
afunc <- function(a) {
for(i in 1:a)
{
b <- i*2
print(b)
}
}
#calling function.
afunc(3)
To embed this project on your website, copy the following code and paste it into your website's HTML: