# Interview Topics

nterms = as.integer(readline(prompt=”How many terms? “)) # first two terms n1 = n2 = 1 count = 2 # check if the number of terms is valid if(nterms <= 0) { print(“Plese enter a positive integer”) } else { if(nterms == 1) { print(“Fibonacci sequence:”) print(n1) } else { print(“Fibonacci sequence:”) print(n1) print(n2) while(count

#### Fibonacci Sequence in R Programming Language

nterms = as.integer(readline(prompt=”How many terms? “)) # first two terms n1 = n2 = 1 count = 2 # check if the number of terms is valid if(nterms <= 0) { print(“Plese enter a positive integer”) } else { if(nterms == 1) { print(“Fibonacci sequence:”) print(n1) } else { print(“Fibonacci sequence:”) print(n1) print(n2) while(count

num = as.integer(readline(prompt = “Enter a number: “)) # use for loop to iterate 10 times for(i in 1:5) { print(paste(num,’x’, i, ‘=’, num*i)) } Output: Enter your number: 8 “8 x 1 = 8” “8 x 2 = 16” “8...

#### Multiplication Table in R Programming Language

num = as.integer(readline(prompt = “Enter a number: “)) # use for loop to iterate 10 times for(i in 1:5) { print(paste(num,’x’, i, ‘=’, num*i)) } Output: Enter your number: 8 “8 x 1 = 8” “8 x 2 = 16” “8...

Sorting of vectors can be done using the sort() function. By default, it sorts in ascending order. To sort in descending order we can pass decreasing=TURE. Note that sort is not in-place. This means that the original vector is not effected (sorted). Only a...

#### Sort a vector in R Programming Language

Sorting of vectors can be done using the sort() function. By default, it sorts in ascending order. To sort in descending order we can pass decreasing=TURE. Note that sort is not in-place. This means that the original vector is not effected (sorted). Only a...

Determines the location, i.e., index of the (first) minimum or maximum of a numeric vector. Usage which.min(x) which.max(x) x <- c( 1, 4, 3, 9, 6, 7) which.max(x) Output: \$Rscript main.r 4 # position {Or} Position particular number(another way) x Output: ...

#### Find the position of minimum and maximum of value in R Programming Language

Determines the location, i.e., index of the (first) minimum or maximum of a numeric vector. Usage which.min(x) which.max(x) x <- c( 1, 4, 3, 9, 6, 7) which.max(x) Output: \$Rscript main.r 4 # position {Or} Position particular number(another way) x Output: ...

x <- c(2 ,3 ,4 ,6,1) min(x) y <- c(78,34,5,67,41,33) max(y) Output: \$Rscript main.r 1 78

#### Find the maximum and minimum number in R Programming Language

x <- c(2 ,3 ,4 ,6,1) min(x) y <- c(78,34,5,67,41,33) max(y) Output: \$Rscript main.r 1 78

x <- c(2 ,3 ,4 ,4) y <-c(3, 4 ,5 ,6) print (x+y) print(x-y) print(x*y) print(x/y) print(x%%y) print(x^y) or sum(x,y) prod(x,y) Output: \$Rscript main.r 5 7 9 10 -1 -1 -1 -2 6 12 20 24 0.6666667 0.7500000 0.8000000 0.6666667...

#### Write a R Program to Two vector Variables (Addition, Subtraction, Multiplication, Division, Mod, Coefficient)

x <- c(2 ,3 ,4 ,4) y <-c(3, 4 ,5 ,6) print (x+y) print(x-y) print(x*y) print(x/y) print(x%%y) print(x^y) or sum(x,y) prod(x,y) Output: \$Rscript main.r 5 7 9 10 -1 -1 -1 -2 6 12 20 24 0.6666667 0.7500000 0.8000000 0.6666667...

2+3 //Add 2-3 //Sub 2*3 //Mul 2/3 //Div 2+2+3*4-4/3 // Add, Mul, Sub, Div Output: 5 -1 6 0.6666667 14.66667 (Or) With input variable: x=6 y=2 x + y x-y x*y x/y Output: 8 4 12 3

#### R Programs to Add, Sub, Mul, and Div

2+3 //Add 2-3 //Sub 2*3 //Mul 2/3 //Div 2+2+3*4-4/3 // Add, Mul, Sub, Div Output: 5 -1 6 0.6666667 14.66667 (Or) With input variable: x=6 y=2 x + y x-y x*y x/y Output: 8 4 12 3

First R Program: print (“Hello world!”) Output: “Hello world!” print (“Hello World!”, quote-FALSE) Output: Hello World! print (paste (“Welcome”,”to”,”my”, “first”,”program”)) Output: “Welcome to my first program”

#### Simple way:” Hello world program in R”

First R Program: print (“Hello world!”) Output: “Hello world!” print (“Hello World!”, quote-FALSE) Output: Hello World! print (paste (“Welcome”,”to”,”my”, “first”,”program”)) Output: “Welcome to my first program”