गुरुर्ब्रह्मा गुरुर्विष्णु गुरुर्देवो महेश्वरा गुरुर्साक्षात परब्रह्म तस्मै श्री गुरवे नमः !
Q1. How do you create a variable named x with the numeric value 5?
int x=5
All of the above
x<-5
x : 5
Correct Answer : x<-5
Q2. How do you insert COMMENTS in R code?
None
// This is a comment
/* This is a comment
Correct Answer : // This is a comment
Q3. What is a correct syntax to output “Hello World” in R?
‘Hello World’
“Hello World”
print(“Hello World”)
All of the other answers are correct
Correct Answer : All of the other answers are correct
Q4. Who is introduced R Programming Language?
Ross Ihaka
Robert Gentleman
Both (A) and (B)
Florian Hahne
Correct Answer : Both (A) and (B)
Q5. When the First appeared R Programming Language?
August 1992
August 1994
August 1993
August 1995
Correct Answer : August 1993
Q6. Which function is often used to concatenate elements?
join()
merge()
paste()
concat()
Correct Answer : paste()
Q7. Which statement is used to stop a loop?
stop
exit
break
return
Correct Answer : break
Q8. Which function is used to find the amount of rows and columns in an array?
dim()
nchar()
length()
dim_len()
Correct Answer : dim()
Q9. How do you start writing a while loop in R?
while x < y:
x < y while
while x < y
while (x < y)
Correct Answer : while (x < y)
Q10. How do you start writing an if statement in R?
if (x > y)
if x > y:
if x > y then:
None of the above
Correct Answer : if (x > y)
Q11. Which function is used to add additional columns in a matrix?
add()
cbind()
join()
append_item()
Correct Answer : cbind()
Q12. Which function is used to draw points (markers) in a diagram?
d()
draw()
plot()
canvas()
Correct Answer : plot()
Q13. How can you assign the same value to multiple variables in one line?
var1, var2, var3 <- “Orange”
var1, var2, var3 = “Orange”
var1, var2, var3 => “Orange”
var1 <- var2 <- var3 <- “Orange”
Correct Answer : var1 <- var2 <- var3 <- “Orange”
Q14. Which operator is used to add together two values?
The & sign
The + sign
The * sign
None of the above
Correct Answer : The + sign
Q15. The following values: 10.5, 55 and 787, belongs to which data type?
numeric
integer
complex
All of the above
Correct Answer : numeric
ASSIGNMENT-1
Q1. Explain Some of the Similarities and Differences Between R and Python.
R and Python are both popular programming languages for data analysis, machine learning, and statistical computing. However, they have some similarities and differences.
Similarities:
Both R and Python have a large and active community of developers and users.
Both languages have a wide range of libraries and frameworks for data analysis, machine learning, and visualization.
Both R and Python are open-source and have similar syntax and constructs, making it relatively easy for developers to switch between the two languages.
Differences:
R is primarily focused on statistical computing and data visualization, while Python is a general-purpose programming language with a larger focus on software development.
R has a more extensive set of libraries and tools specifically designed for data analysis and statistical computing, while Python has a larger set of libraries and frameworks for software development.
R has a more concise and expressive syntax for data analysis, making it easier to work with data, while Python has more flexibility in terms of object-oriented programming and web development.
Python has a wider range of use cases than R. R is mainly used in data science, statistics, and data visualization, while Python can be used in web development, data science, artificial intelligence, and more.
In summary, R and Python are both popular programming languages for data analysis, machine learning, and statistical computing, but they have some similarities and differences. R is more focused on data analysis and statistics, while Python is a more general-purpose programming language. R has a more extensive set of libraries for data analysis, and Python has a larger set of libraries for software development. Both languages have a large and active community of developers, and many developers are proficient in both R and Python.
Q2. Write and Explain Some of the Most Common Syntaxes in R?
R is a powerful programming language for data analysis, statistics, and visualization. Here are some common syntaxes in R:
Assigning variables: In R, variables can be assigned a value using the assignment operator <-. For example, x <- 5 assigns the value 5 to the variable x. You can also use = for assignment, for example, x = 5
Vectors: Vectors are one-dimensional arrays of data in R. They can be created using the c() function, for example, x <- c(1, 2, 3, 4, 5) creates a vector of the integers 1 to 5.
Data frames: Data frames are two-dimensional arrays of data in R. They can be created using the data.frame() function, for example, df <- data.frame(x = c(1, 2, 3), y = c("a", "b", "c")) creates a data frame with two columns, x and y.
Subsetting: R allows you to extract specific elements from a vector or data frame using indexing. For example, x[2] returns the second element of the vector x.
Control flow: R supports control flow statements such as if-else and for loops. For example, for(i in 1:5) {print(i)} will print the numbers from 1 to 5.
Q3. (a) How Do You Assign a Variable in R?
(b) List Some of the Best Packages For:
i. Data Visualization
ii. Data Mining
iii. Data Imputation
a) To assign a variable in R, you can use the assignment operator <-. For example, x <- 5 assigns the value 5 to the variable x. You can also use = for assignment, for example, x = 5.
b) Here are some of the best packages for:
i. Data Visualization: ggplot2, lattice, plotly, rbokeh, leaflet, and ggvis
ii. Data Mining: caret, rpart, randomForest, arules, and e1071
iii. Data Imputation: VIM, Amelia, Hmisc, mice, and missForest