Data Science Using R
Data Science Using R
No
. Question Option A Option B Option C Option D Answer
1 What is the full form of R in the context of data analysis? Regression R Project Randomization Runtime R Project
3 Which of the following is NOT a commonly used IDE for R? RStudio Jupyter Notebook Notepad++ PyCharm Notepad++
4 What is the command to install a package in R? install.pkg() install.packages() library() load.pkg() install.packages()
5 How do you check the working directory in R? get.dir() getwd() dir.get() pwd() getwd()
6 Which of these is a basic data type in R? String Dictionary Tuple Data Frame String
9 What does NA represent in R? Non-assignable value Not Available (Missing) Numeric Array Null Attribute Not Available (Missing)
10 How do you combine elements into a vector in R? combine() c() vector() concat() c()
15 What is the default way to read CSV files in R? read_csv() read.csv() import_csv() load_csv() read.csv()
16 What function is used to create a data frame in R? data.frame() create_df() frame() new.data.frame() data.frame()
17 Which package is primarily used for data manipulation in R? dplyr ggplot2 tidyr readr dplyr
18 How do you install the dplyr package? install.dplyr() install.packages() library(dplyr) install_dplyr() install.packages()
19 What does the select() function in dplyr do? Select rows Select columns Filter rows Rename columns Select columns
23 How do you rename columns in a data frame using dplyr? rename() colnames() set_names() modify_col() rename()
24 How can missing values be identified in R? check.NA() is.na() NA() na_check() is.na()
26 What is the primary object type for storing tabular data in R? Data Frame List Array Vector Data Frame
29 Which function in dplyr is used for summarizing data? summary() summarize() aggregate() summ() summarize()
30 What function loads an external package in R? load() library() install() require() library()
31 How do you write data to a CSV file in R? write.csv() save_csv() export_csv() save() write.csv()
33 How do you check the data type of an object in R? typeof() type() datatype() class() typeof()
34 Which of these is used to concatenate strings in R? cat() concat() paste() join() paste()
35 Which function converts a data frame column into a factor? as.factor() convert.factor() make.factor() to_factor() as.factor()
36 How do you remove missing values from a vector? remove.na() na.omit() omit.na() drop_na() na.omit()
37 What is the default separator when reading a CSV file in R? Comma Tab Space Semicolon Comma
40 How do you combine two data frames vertically in R? combine() rbind() cbind() vbind() rbind()
43 How do you list all objects in the current workspace? list() ls() objects() show_objects() ls()
44 How can you remove an object from the workspace? delete(obj) rm(obj) remove(obj) del(obj) rm(obj)
47 What does %>% represent in dplyr? Pipe operator Logical OR Logical AND Concatenation Pipe operator
48 How do you check installed R packages? installed.packages() check.packages() list.packages() packages.list() installed.packages()
49 How do you remove a column from a data frame in R? drop() select(-column_name) remove_column() delete.column() select(-column_name)
50 How do you add a new column to a data frame in R? mutate() add_column() append_column() cbind() mutate()
52 How can you group data based on a column in dplyr? arrange() group_by() filter() summarize() group_by()
54 How do you load a CSV file as a data frame? load.csv() read.csv() import_csv() load.data() read.csv()
55 Which of the following is not a data type in R? Integer Character Tuple Logical Tuple
56 What function is used to create sequences in R? seq() range() sequence() seq.range() seq()
57 Which of these methods cannot be used to subset data? Logical conditions Using indices Using $ Using @ Using @
59 What is the primary purpose of the tidyr package? Data visualization Data manipulation Data cleaning Data import/export Data cleaning
The else statement is executed when the if condition is: TRUE FALSE NULL Undefined FALSE
2
Which keyword is used to exit a loop prematurely? stop break next exit break
3
What does the next statement do in a loop? Skips current iteration Stops the loop Restarts the loop Exits the loop Skips current iteration
4
Repeat commands for
The for loop in R is used to: Iterate over elements Infinite looping Recursive operations Iterate over elements
5 specific times
Executes until a Executes for a fixed Executes until a
What is the purpose of a while loop? Executes indefinitely Executes only once
6 condition is met number condition is met
What will for(i in 1:3) print(i) output? NULL Error 123 Prints nothing 123
7
function() funct() function()
How do you create a user-defined function in R? def() keyword lambda() keyword
8 keyword keyword keyword
Which function checks argument names in R? argnames() formals() match.args() argument() match.args()
9
Arguments are Arguments are Arguments are always Arguments are
What does "lazy evaluation" mean in R functions? Arguments are ignored
10 evaluated eagerly evaluated as needed NULL evaluated as needed
Pass unknown Limit function Pass unknown
The ... argument in a function is used to: End function execution Repeat arguments
11 arguments parameters arguments
Which function is used for splitting data into subsets? divide() split() subset() tapply() split()
15
The tapply() function applies a function to: Rows Columns Groups Individual elements Groups
16
Which function calculates row sums in a matrix? apply() rowSums() colSums() rowMeans() rowSums()
17
Which function allows simultaneous iteration over multiple
mapply() tapply() rapply() capply() mapply()
18 arguments?
The split() function is particularly useful for: Grouping data Merging data Sorting data Flattening lists Grouping data
20
Which control structure is best used when the number of
for loop while loop repeat loop break loop while loop
21 iterations is not known in advance?
What happens if the condition in a while loop never becomes
Stops immediately Infinite loop Skips iterations Executes once Infinite loop
22 FALSE?
What is the purpose of return() in an R function? To stop the loop To return a value To skip an argument To restart the function To return a value
23
Which of the following is not a valid R control structure? repeat do-while if-else for do-while
24
Element-wise
The apply() function is mainly used for: Row-wise operations Array/matrix operations Conditional execution Array/matrix operations
25 operations
colMeans() calculates: Column means Row means Element means Group means Column means
26
The result of sapply(list(1:3, 4:6), mean) is: A list A vector A matrix NULL A vector
27
What does split(1:10, rep(1:2, each = 5)) return? A vector A list A matrix NULL A list
28
Which loop function is best for applying a function across
mapply() tapply() rapply() sapply() mapply()
29 multiple objects at once?
What does the following function return? function(x = 1, y) x +
Error x+y x NULL Error
30 y
What is the output of if(FALSE) { print("Yes") } else {
Yes No Error NULL No
31 print("No") }?
Which function is used to get cumulative sums of a vector? sum() cumsum() rowSums() cummean() cumsum()
32
What does the names() function do for lists or vectors? Assigns dimensions Assigns/returns names Changes length Returns classes Assigns/returns names
33
Checks function Displays function Changes function Returns function Displays function
What is the use of the formals() function?
34 arguments arguments arguments output arguments
Lazy evaluation delays argument evaluation until: Argument definition Argument use Argument pass Argument return Argument use
35
apply() can operate on: Lists Vectors Arrays NULL Arrays
36
Which function can split a data frame by factors? split() subset() divide() group() split()
37
Generate repeated Generate repeated
The replicate() function is used to: Repeat vectors Create multiple loops None of the above
38 simulations simulations
The mapply() function is a multivariate version of: lapply() sapply() tapply() apply() lapply()
41
In a custom function, default argument values are specified: Using "=" Using "<-" Using "->" Using ":" Using "="
42
Which function calculates cumulative products in R? cumprod() cumsum() cummean() None of the above cumprod()
43
The dim() function can be applied to: Vectors Matrices and arrays Data frames only Scalars Matrices and arrays
44
Which function returns row indices where a condition is met? rowSums() which() where() apply() which()
45
What will split(mtcars, mtcars$cyl) do? Split into cylinders Error Split into groups Split into lists Split into groups
46
Which of these loop functions does not simplify results? sapply() vapply() lapply() apply() lapply()
47
Which loop function works for vectors with length constraints? vapply() lapply() sapply() rapply() vapply()
48
Which loop is guaranteed to execute at least once? for while repeat None of these repeat
49
Return object
What is the role of cat() in R? Combine vectors Print to the console Create data frames Print to the console
50 structure
A vector of squared
What is returned by lapply(1:3, function(x) x^2)? A list of squared values A matrix NULL A list of squared values
51 values
Can ifelse() return different types of values? Yes No Only numeric values Only logical values Yes
52
Which function is used to repeat an action indefinitely? for while repeat mapply() repeat
53
Check mode of a Check length of a
The typeof() function is used to: Check type of a variable Check dimensions Check type of a variable
54 variable variable
The t() function in R is used to: Transpose a matrix Calculate mean Multiply elements None of the above Transpose a matrix
55
Depends on margin Depends on margin and
What does apply() return when used on a data frame? A vector A matrix A data frame
56 and function function
Which function calculates column means efficiently? rowMeans() colMeans() apply() tapply() colMeans()
57
Which of these supports anonymous functions? apply() lapply() sapply() All of the above All of the above
58
Which R function checks if all elements of a vector satisfy a
all() any() sum() mean() all()
59 condition?
How can you extract the first element of each group in a list? lapply(list, first) sapply(list, "[[", 1) apply(list, 1) None of the above sapply(list, "[[", 1)
60
What is the primary purpose of data visualization in
1 Data storage Data presentation Data transformation Data cleaning Data presentation
descriptive analytics?
2 Which R function is commonly used to create bar charts? plot() barplot() hist() pie() barplot()
4 In R, which function is used to add a title to a plot? main() title() add.title() plot.title() main()
5 What does the pch parameter control in R plots? Line width Marker type Color of the plot Size of the plot Marker type
Using the barcol Using the color Using the barColor
6 How can you change the color of a bar in a bar chart in R? Using the col argument Using the col argument
argument function argument
7 Which function is used to create line graphs in R? line() lines() plot() graph() lines()
9 What does the legend() function in R do? Adds a legend to a plot Sets plot labels Adjusts color settings Creates line graphs Adds a legend to a plot
11 In a line graph, what does the type = "l" argument signify? Add points Draw a line Add a legend Set line width Draw a line
14 Which package is used in R for creating geographical maps? maps ggplot2 mapdata All of the above All of the above
15 Which function in R is used to add grid lines to a plot? grid() abline() lines() points() grid()
Highlighted as separate
16 How do you represent missing data in plots in R? NA points removed Transparent points All of the above All of the above
category
17 Which function is used to create a histogram in R? barplot() hist() scatter() pie() hist()
18 Which argument adjusts the legend position in ggplot2? pos legend.pos legend.position position legend.position
19 Which R function is used to create boxplots? plot() boxplot() bplot() ggboxplot() boxplot()
21 What is the default shape of points in ggplot2 scatter plots? Circle Triangle Square Cross Circle
22 Which function is used in ggplot2 to set axis labels? labs() xlabel() ylab() set_axis() labs()
23 In R, which function combines multiple plots into one window? par() layout() grid.arrange() combine() grid.arrange()
29 Which function in ggplot2 is used to add lines to a plot? geom_lines() geom_line() geom_path() geom_add() geom_line()
30 Which function is used to save plots created with ggplot2? save_plot() ggsave() save() plot.save() ggsave()
32 Which function in ggplot2 is used to create density plots? geom_density() density_plot() geom_area() geom_smooth() geom_density()
33 How do you represent a continuous variable as color in ggplot2? Using fill Using aes(color) Using aes(size) Using aes(shape) Using aes(color)
38 How do you add custom icons to a map in the leaflet package? add_custom() addCustomIcons() icon() addIcons() icon()
39 What type of plot does the ggmap package primarily support? Bar plots Line graphs Geographical maps Histograms Geographical maps
40 What is the main function of geom_boxplot() in ggplot2? Creating scatter plots Creating bar charts Creating box plots Creating line graphs Creating box plots
44 What does the fill aesthetic control in ggplot2? Point size Line width Color of filled areas Data transparency Color of filled areas
45 What is the default theme in ggplot2? theme_gray() theme_bw() theme_minimal() theme_classic() theme_gray()
46 Which function in base R creates pie charts? piechart() pie() chart_pie() pie_graph() pie()
47 Which argument is used to add grid lines in a ggplot2 plot? grid() theme(panel.grid) panel_grid() grid_lines() theme(panel.grid)
48 Which function creates a heatmap in base R? heat() heatmap() geom_heat() plot_heat() heatmap()
49 How can you visualize frequency distribution in ggplot2? geom_histogram() geom_boxplot() geom_density() geom_bar() geom_histogram()
52 Which function adds a smooth line to a scatter plot in ggplot2? geom_path() geom_smooth() geom_line() geom_curve() geom_smooth()
53 In ggplot2, how do you set the x-axis limits? xrange() xlim() x_limits() coord_x() xlim()
54 Which visualization technique is best for showing proportions? Scatter plot Bar chart Pie chart Line graph Pie chart
55 What does the labs() function allow you to do? Change plot titles Modify axis labels Both A and B None of the above Both A and B
57 Which of the following creates a vertical bar chart in ggplot2? geom_vbar() geom_col() geom_bar() geom_vert() geom_bar()
58 What is the default coordinate system in ggplot2? Cartesian Polar Logarithmic Geographical Cartesian
59 Which function in ggplot2 modifies legend properties? legend() theme() modify_legend() set_legend() theme()
60 Which argument adjusts the angle of axis text in ggplot2? text.angle angle.axis axis.text.angle angle axis.text.angle
1 Which function in R calculates the square root of a number? sqrt() abs() log() round() sqrt()
Calculate the absolute Calculate the absolute
2 The function abs() in R is used to: Calculate logarithm value Round off a number Find square root value
3 What is the purpose of the mean() function in R? Calculate median Calculate variance Calculate mean Calculate sum Calculate mean
Which function in R computes the standard deviation of a
4 dataset? sd() var() sqrt() summary() sd()
Both minimum and Both minimum and
5 The function range() in R returns: The range of a dataset The minimum value The maximum value maximum values maximum values
6 Which function is used to compute variance in R? sd() mean() var() range() var()
Basic statistical Cumulative frequency Basic statistical
7 The summary() function in R provides: summary Frequency distribution Box-plot visualization distribution summary
Compute standard
8 What does the scale() function in R do? Normalize data Find the mean deviation Calculate variance Normalize data
9 Which of the following functions calculates correlation in R? cor() cov() sd() var() cor()
Summarize a dataset Plot cumulative Summarize a dataset
10 A boxplot is used to: Display frequencies visually distribution Create pie charts visually
11 What is the output of the cov() function in R? Variance Correlation matrix Covariance matrix Standard deviation Covariance matrix
Show frequency Represent Show frequency
12 What is the primary use of a histogram? Compare categories distribution Visualize relationships proportions distribution
Which type of plot is ideal for visualizing the relationship
13 between two continuous variables? Histogram Scatterplot Boxplot Pie chart Scatterplot
14 In R, which function is used to create a pie chart? pie() barplot() hist() plot() pie()
15 What does the quantile() function in R calculate? Mean Quartiles Standard deviation Range Quartiles
16 The log10() function in R computes: Natural logarithm Base-10 logarithm Exponential function Square root Base-10 logarithm
17 Which function generates random numbers in R? random() rnorm() runif() Both B and C Both B and C
Generate random
18 The function set.seed() in R is used to: numbers Set a random seed Solve distributions Normalize a dataset Set a random seed
Which function simulates random sampling for a binomial
19 distribution in R? rbinom() rnorm() rpois() rexp() rbinom()
Solve binomial Simulate Poisson Simulate Poisson
20 What is the purpose of rpois() in R? problems distribution Normalize data Create histograms distribution
Which R function generates random numbers for a normal
21 distribution? rnorm() rbinom() runif() rexp() rnorm()
Exponential random Poisson random Normal random Uniform random Exponential random
22 What does rexp() in R generate? numbers numbers numbers numbers numbers
23 Which function creates a bar chart in R? hist() barplot() pie() boxplot() barplot()
Cumulative frequency Cumulative frequency
24 What type of table displays cumulative frequency distribution? Frequency table Contingency table table Summary table table
Which R function is used to calculate the product of all
25 elements in a vector? prod() sum() mean() range() prod()
26 What is a key feature of a box-and-whisker plot? Frequency distribution Quartiles and outliers Mean and median Random samples Quartiles and outliers
27 What is the output of the min() function in R? Minimum value Maximum value Range Mean Minimum value
How does the summary() function handle categorical Displays frequency Calculates mean and Displays frequency
28 variables? Shows quartiles distribution variance Ignores them distribution
29 Which plot is best for visualizing proportions of categories? Pie chart Histogram Scatterplot Boxplot Pie chart
30 What does the max() function in R return? Maximum value Minimum value Average value Standard deviation Maximum value
Rounds a number to an Rounds a number to Rounds a number to
31 What does the round() function in R do? integer specified decimals Finds the range Normalizes a dataset specified decimals
Which R function creates random numbers from a uniform
32 distribution? runif() rnorm() rbinom() rexp() runif()
35 Which argument in rnorm() specifies the mean? sd lambda mean center mean
36 What does the rbinom() function's size argument represent? Number of trials Probability of success Number of bins Size of plot Number of trials
37 Which distribution is simulated using rpois()? Exponential Poisson Binomial Normal Poisson
Which function visualizes cumulative frequency distributions in
38 R? hist() barplot() pie() ecdf() ecdf()
40 What is the default base of the log() function in R? e (natural log) 2 10 None of the above e (natural log)
43 Which R function is used to compute covariance? cor() cov() var() summary() cov()
44 Which argument in rpois() specifies the rate parameter? lambda prob mean size lambda
45 How can the axis limits of a histogram be adjusted in R? Using xlim() Using ylim() Both A and B Using grid() Both A and B
Compute the arithmetic Compute standard Compute the arithmetic
46 What is the purpose of the mean() function? Compute the median mean deviation Compute mode mean
Which plot is best for visualizing data spread and potential
47 outliers? Histogram Boxplot Bar Chart Pie Chart Boxplot
48 How is a normal distribution simulated in R? Using rnorm() Using rpois() Using runif() Using rexp() Using rnorm()
49 What does the sum() function in R return? Total of elements Mean value Count of elements Product of elements Total of elements
50 Which argument in hist() specifies the number of bins? bin breaks bins split breaks
Showing a frequency Visualizing summary Simulating random Visualizing summary
51 The boxplot() function is used for: table statistics Creating scatter plots numbers statistics
52 How is the cumulative frequency of a dataset calculated? Using cumsum() Using cumprod() Using sum() Using range() Using cumsum()
53 What is the use of the prod() function in R? Compute mean Compute product Compute range Compute variance Compute product
57 Which R function is used to display frequency distribution? freq() table() hist() barplot() table()
58 Which plot would best represent proportions? Histogram Bar Chart Pie Chart Scatter Plot Pie Chart
How are random numbers generated for exponential
59 distribution? Using rpois() Using rbinom() Using rexp() Using runif() Using rexp()
What is the purpose of setting a seed in random number Generate cumulative
60 generation? Ensure reproducibility Change randomness Increase randomness distribution Ensure reproducibility
S.N
o. Questions
Explain the role of basic arithmetic operations and standard
functions like abs(), sqrt(), log(), and round() in data analysis.
1 Provide examples of their applications in R.
Discuss the use of statistical functions such as mean(), var(),
sd(), and quantile() in summarizing data. How do these
2 functions help in understanding the distribution of a dataset?
What is the purpose of the summary() function in R? Illustrate
how it provides a comprehensive overview of both numeric
3 and categorical data.
Describe the differences between a frequency distribution
table and a cumulative frequency distribution table. How can
4 these be constructed and visualized in R?
Explain the purpose of various plots like bar charts, pie charts,
histograms, and scatterplots in data visualization. Discuss
5 scenarios where each is most effective.
What is a Box-Whisker Plot? Explain its components, such as
the median, quartiles, and outliers, and provide an example of
6 how to create one in R.
Describe the process of simulating random numbers in R. How
do functions like runif(), rnorm(), and rpois() differ, and what
7 are their specific use cases?
Explain the importance of setting a random seed using
set.seed() in simulations. How does it ensure reproducibility in
8 random number generation?
Discuss how R can be used to solve problems related to
binomial, Poisson, normal, and exponential distributions.
9 Provide examples of functions like rbinom(), rpois(), rnorm(),
How can correlation and covariance be computed in R using
cor() and cov()? Discuss the differences between these two
10 measures and their significance in data analysis.
Explain the role of data visualization in descriptive analytics.
How does it help in identifying patterns and trends? Provide
1 examples of common visualization methods used.
Describe the differences between bar charts, line graphs, and
scatter plots. In what scenarios would you use each type of
2 visualization?
How can you edit charts and graphs in R using colors, size, and
legends? Provide examples demonstrating these
3 customizations.