Q 31) "tidyr" package is often used to perform data cleaning task in R.
Which
of the following command will combine "Male" and "Female" column into a
single column named "Sex" and create another variable named "Count" as the
count of male or female "Name" wise.
Initial dataframe
Name Male Female
A 1 6
B 5 9
Output Dataframe
Name Sex Count
A Male 1
B Male 5
A Female 6
B Female 9
dmCQmCieac2OT 8ZMHFKE2KIIK
collect(dataframe,Male:Female,Sex,Count)
gather(dataframe,Sex,Count,-Name)
gather(dataframe,Sex,Count)
collect(dataframe,Male:Female,Sex,Count,-Name)
Q 32) The dataframe below contains one category of messy data where
multiple columns are stacked into one column which is highly undesirable.
Sex_Class Count
Male_1 1
Male_2 2
Female_1 3
Female_2 4
Which of the following code will convert the above dataframe to the
dataframe below ? The dataframe is stored in a variable named "dataframe".
Sex Class Count
Male 1 1
Male 2 2
Female 1 3
Female 2 4
dmCQmCieac2OT FJ 2G12UGL7VG
separate(dataframe,Sex_Class,c("Sex","Class"))
split(dataframe,Sex_Class,c("Sex","Class"))
disjoint(dataframe,Sex_Class,c("Sex","Class"))
None of the above
Q 33) The dataset ("dataframe") below suffers from a problem where
variables “Term” and “Grade” are stored in separate columns which can be
displayed more effectively. We wish to convert the structure of these
variables into each separate variable named "Mid" and "Final".
Name Class Term Grade
Alaska 1 Mid A
Alaska 1 Final B
Banta 2 Mid A
Banta 2 Final A
Which of the following code will convert the above dataset into the one shown
below?
Name Class Mid Final
Alaska 1 A B
Banta 2 A A
dmCQmCieac2OT 5NPDUE18ARVF
melt(dataframe, Term, Mid,Final,Grade)
transform(dataframe,unique(Term),Grade)
spread(dataframe,Term,Grade)
None of the above
Q 34) The ________ function takes an arbitrary number of arguments and
concatenates them one by one into character strings
dmCQmCieac2OT Z1GUW5HQSBLF
copy()
paste()
bind()
None of the above.
Q 35) Point out the correct statement :
dmCQmCieac2OT KF0TFYS1X318
Character strings are entered using either matching double or single quote.
Character vectors may be concatenated into a vector by the c() function.
Subsets of the elements of a vector may be selected by appending to the name of
the vector an index vector in square brackets.
All of the above
Q 36) What will be the output of the following code ?
> x <- 1:3
> y <- 10:12
> rbind(x, y)
dmCQmCieac2OT BQ1P7W4T72KY
[,1] [,2] [,3]
x 1 2 3
y 10 11 12
[,1] [,2] [,3]
x 1 2 3
y 10 11
[,1] [,2] [,3]
x 10 0 36
y 10 11 12
All of the above
Q 37) Which of the following method make vector of repeated values?
dmCQmCieac2OT M4354V964CWV
rep()
data()
view()
None of the above
Q 38) Which of the following finds the position of quantile in a dataset ?
dmCQmCieac2OT Z6TG8RV1A9YV
quantile()
barplot()
barchart()
None of the Above
Q 39) Which of the following function cross-tabulate tables using formulas ?
dmCQmCieac2OT VKA5PKBBCF6G
table()
stem()
xtabs()
All of the above
Q 40) What is the output of the following function
> f <- function(num = 1) {
+ hello <- "Hello, world!\n"
+ for(i in seq_len(num)) {
+ cat(hello)
+ }
+ chars <- nchar(hello) * num
+ chars
+ }
> f()
dmCQmCieac2OT 03VUJ 8LOSZ2O
Hello, world!
14
Hello, world!/n
14
Hello, world!
13
Hello, world!/n
13
Q 41) Which is the missing metric from running the quantile function on a
numeric vector in comparison to running the summary function on the same
vector?
dmCQmCieac2OT 3Z0K3PA82QQD
Median
Mean
Maximum
Minimum
Q 42) Which of the following command will plot a blue boxplot of a numeric
vector named "vec"?
dmCQmCieac2OT 75SB61XVVNW7
boxplot(vec,col="blue")
boxplot(vec,color="blue")
boxplot(vec,color="BLUE")
None of the above
Q 43) Which of the following command will create a histogram with 100
buckets of data ?
dmCQmCieac2OT XCGBO23GAVU0
hist(vec,buckets=100)
hist(vec,into=100)
hist(vec,breaks=100)
None of the above
Q 44) what does the “main” parameter in barplot command does ?
dmCQmCieac2OT 2UAQ9F1U50W4
The x- axis label
Title of the graph
Legends in the graph
y-axis label
Q 45) The below dataframe is stored in a variable named "sam":
A B
12 East
15 West
13 East
15 East
14 West
We wish to create a boxplot in a single line of code per "B" i.e a total of two
boxplots (one for East and one for West). Which of the following command will
achieve the purpose?
dmCQmCieac2OT T1SUDY0Z32ZF
boxplot(A~B,data=sam)
boxplot(A,B,data=sam)
boxplot(A|B,data=sam)
None of the above
Q 46) Which of the following command will split the plotting window into 3 X 4
sub windows and where the plots enter the window row wise.
dmCQmCieac2OT 90J WLVKN1HIN
par(split=c(3,4))
par(mfcol=c(3,4))
par(mfrow=c(3,4))
par(col=c(3,4))
Q 47) A dataframe named "frame" contains two numerical columns named "A"
and "B". Which of the following command will draw a scatter plot between the
two columns of the dataframe?
dmCQmCieac2OT 63YZ94AWN2UL
with(frame,plot(A,B))
plot(frame$A,frame$B)
ggplot(data = frame, aes(A,B))+geom_point()
All of the above
Q 48) The dataframe below is stored in a variable named "frame".
A B C
15 42 East
11 31 West
56 54 East
45 63 East
12 26 West
Which of the following command will draw a scatter plot between "A" and "B"
differentiated by different color of "C" like the one below.
dmCQmCieac2OT I0PQLAX4W493
plot(frame$A,frame$B,col=frame$C)
with(frame,plot(A,B,col=C)
1 and 2
None of the above
Q 49) Which of the following does not apply to R’s base plotting system ?
dmCQmCieac2OT AX13AHI9E7OP
Can easily go back once the plot has started (eg: to change margins etc).
It is convenient and mirrors how we think of building plots and analysing data
starts with plot(or similar) function
Use annotation functions to add/modify (text, lines etc)
Q 50) Which of the following function is used to create plots in ggplot2?
dmCQmCieac2OT H817LWQDMSIO
qplot
gplot
plot
xyplot
Q 51) What is true regarding the relation between the number of plots drawn
by 'facet_wrap" and "facet_grid" ?
dmCQmCieac2OT AQ1XVMAOFBZ2
facet_wrap>facet_grid
facet_wrap<facet_grid
facet_wrap<= facet_grid
None of the above
Q 52) Which function in ggplot2 allows the coordinates to be flipped? (i.e x
becomes y and vice-versa) ?
dmCQmCieac2OT WQAFQ7VQ3T1Y
coordinate_flip
coord_flip
coordinate_rotate
coord_rotate
Q 53) The below dataset is stored in a variable called "frame".
A B
Alpha 100
Beta 120
Gamma 80
Delta 110
Which of the following command will create a bar plot for the above dataset
with the values in column "B" being the height of the bar?"
dmCQmCieac2OT KB9TGAE0GOKV
ggplot(frame,aes(A,B))+geom_bar(stat="identity")
ggplot(frame,aes(A,B))+geom_bar(stat="bin")
ggplot(frame,aes(A,B))+geom_bar()
None of the above
Q 54) The following dataframe is stored in a variable named "frame" and is a
subset of a very popular dataset named
"mtcars".
We wish to create a stacked bar chart for "cyl" variable with stacking criteria
being "vs" variable. Which of the following command will help us do this ?
dmCQmCieac2OT 5S7SUCBMU8D7
qplot(factor(cyl),data=frame,geom="bar",fill=factor(vs))
ggplot(mtcars,aes(factor(cyl),fill=factor(vs)))+geom_bar()
Both 1 and 2
None of the above
Q 55) The question is same as previous one . The only difference is that you
have to create a dodged bar chart instead of a stacked one. Which of the
following command will help us do that ?
dmCQmCieac2OT VJ MYK0ZRFRKX
qplot(factor(cyl),data=frame,geom="bar",fill=factor(vs),position="dodge")
ggplot(mtcars,aes(factor(cyl),fill=factor(vs)))+geom_bar(position="dodge")
All of the above
None of the above