1. A data analyst is assigning a
variable to a value in their company’s sales dataset for 2020. Which variable
name uses the correct syntax?
Answers
·
-sales-2020
·
2020_sales
·
sales_2020
·
_2020sales
Explanation: "sales_2020"
is the name of the variable, and "500000" is the value that has been
allocated to it in this case. It is usual practice to use the underscore
character (_) to separate words in variable names, which makes the names easier
to read. The use of snake case is another name for this behavior. When
assigning, the equal symbol (=) is often used.
2. You want to create a vector with
the values 12, 23, 51, in that exact order. After specifying the variable, what
R code chunk allows you to create the vector?
Answers
·
c(12,
23, 51)
·
v(12,
23, 51)
·
c(51,
23, 12)
·
v(51,
23, 12)
3.
An analyst runs code to convert string data into a date/time data type that
results in the following: “2020-07-10”. Which of the following are examples of
code that would lead to this return? Select all that apply.
Answers
·
mdy(“July 10th, 2020”)
·
ymd(20200710)
·
myd(2020,
July 10)
·
dmy(“7-10-2020”)
4.
A data analyst inputs the following code in RStudio:
change_1 <- 70
Which of the following types of operators does the analyst use in the code?
change_1 <- 70
Which of the following types of operators does the analyst use in the code?
Answers
·
Assignment
·
Logical
·
Relational
·
Arithmetic
Explanation: The analyst makes use of the
assignment operator (-) in the R code samples that are supplied here. In R,
assigning values to variables is accomplished with the help of this operator.
5. A data analyst is deciding on
naming conventions for an analysis that they are beginning in R. Which of the
following rules are widely accepted stylistic conventions that the analyst
should use when naming variables? Select all that apply.
Answers
·
Use
single letters, such as “x” to name all variables
·
Use an underscore to separate words within a
variable name
·
Begin
all variable names with an underscore
·
Use all lowercase letters in variable names
6. In R, what includes reusable
functions and documentation about how to use the functions?
Answers
·
Pipes
·
Comments
·
Packages
·
Vectors
7. Packages installed in RStudio are
called from CRAN. CRAN is an online archive with R packages and other R-related
resources.
Answers
·
True
·
False
8. A data analyst is reviewing some
code and finds the following code chunk:
mtcars %>%
filter(carb > 1) %>%
group_by(cyl) %>%
What is this code chunk an example of?
Answers
·
Pipe
·
Nested
function
·
Vector
·
Data
frame
Answers
·
1021
·
1020
·
1102
·
2120
Answers
·
R script file names should end in “.R”
·
R
script file names should end in “.S”
·
R
script file names should end in “.rscript”
·
R
script file names should end in “.r-script”
Answers
·
Recommended
packages are made by the community and base packages are not.
·
Base
packages take longer to load than recommended packages.
·
Base packages are installed and loaded by
default and recommended packages are not.
·
Recommended
packages are more professionally designed than base packages.
12.
Why would a data analyst want to use the CRAN network when working with
RStudio?
Answers
·
To
add new operators to R
·
To
install R packages
·
To
add pipes to R
·
To
install drivers to RStudio
13.
A data analyst wants to take a data frame named people and filter the data
where age is 10, arranged by height, and grouped by gender. Which code snippet
would perform those operations in the specified order?
Answers
Explanation: You may use the dplyr
package in R to filter a data frame called persons where the age is 10,
organize the data by height, and group it by gender.
14.
Which of the following are examples of variable names that can be used in R?
Select all that apply.
Answers
·
autos_5
·
utility2
·
3_sales
·
_red_1
15. You want to create a vector with
the values 43, 56, 12 in that exact order. After specifying the variable, what
R code chunk lets you create the vector?
Answers
·
c(43, 56, 12)
·
v(12,
56, 43)
·
v(43,
56, 12)
·
c(12,
56, 43)
16.
An analyst comes across dates listed as strings in a dataset. For example,
December 10th, 2020. To convert the strings to a date/time data type, which
function should the analyst use?
Answers
·
lubridate()
·
datetime()
·
now()
·
mdy()
Answers
·
Relational
·
Logical
·
Arithmetic
·
Assignment
Answers
· patient_details_1.R
·
title*123.R
·
p1+infoonpatients.R
·
patient_data.R
Answers
·
Naming
conventions for R variable names
·
Reusable R functions
·
Tests for checking your code
·
Sample datasets
Answers
·
The CRAN archive
·
The
RStudio website
·
The
tidyverse
·
Python
21. A data analyst writes
the following code in a script and gets an error. What is wrong with their code?
penguins %>%
filter(flipper_length_mm == 200) %>%
group_by(species) %>%
summarize(mean = mean(body_mass_g)) %>%
Answers
·
They
are using too many functions.
·
The last line should not have a pipe operator.
·
The
first line should have a pipe operator before penguins.
·
They
are using the wrong characters for the pipe operator.
22.
Fill in the blank: When creating a variable for use in R, your variable name
should begin with _____.
Answers
·
an
operator
·
a letter
·
an
underscore
·
a
number
Answers
·
c(39,
12, 21)
·
v(39,
12, 21)
·
v(21,
12, 39)
·
c(21, 12, 39)
Answers
·
“4.10.19”
·
“4/10/2019”
·
“2019-10-4”
·
“2019-4-10”
Answers
·
Arithmetic
·
Conditional
·
Logical
·
Assignment
Answers
·
p1+infoonpatients.R
·
patient_data.R
·
patient_details_1.R
·
title*123.R
Answers
·
A
data frame
·
A
tidyverse
·
A
data type
·
A package
28. A data analyst needs a system of
packages that use a common design philosophy for data manipulation,
exploration, and visualization. What set of packages fulfills their need?
Answers
·
Base
·
CRAN
·
tidyverse
·
Recommended
Shuffle Q/A 3
Answers
·
alpha_21
·
alpha21
·
tidyverse
·
Recommended
Answers
·
v()
·
c()
·
vector()
·
combine()
31. What type of
packages are automatically installed and loaded to use in R studio when you
start your first programming session?
Answers
·
Recommended packages
·
Base packages
·
Community packages
·
CRAN packages
Explanation: When you begin your first programming session in RStudio, many critical foundation packages are immediately connected. These packages provide vital capabilities for fundamental data manipulation, analysis, and visualization.
32. Why would you want
to use pipes instead of nested functions in R? Select all that apply.
Answers
·
Pipes make it easier to
add or remove functions.
·
Pipes make it easier to
read long sequences of functions.
·
Nested functions are no longer
supported by R.
·
Pipes allow you to combine more
functions in a single sequence.
33. Which of the
following are examples of variable names that can be used in R?
Answers
·
value(2)
·
value-2
·
value_2
·
value%2
34. A data analyst has a
dataset that contains date strings like "January 10th, 2022." What
lubridate function can they use to convert these strings to dates?
Answers
·
myd()
·
mdy()
·
dmy()
·
ymd()
Explanation: In this demonstration, the Date object that corresponds to January 10, 2022 will be allotted to the converted_date variable. When it comes to dealing with dates and times in R, the powerful lubridate package has a function called mdy() that is responsible for handling a variety of formats.
35. What is the
relationship between RStudio and CRAN?
Answers
·
RStudio and CRAN are both environments
where data analysts can program using R code.
·
CRAN creates visualizations based on
an analyst’s programming in RStudio.
·
CRAN contains all of the data that
RStudio users need for analysis.
· RStudio installs packages from CRAN that are not in Base R.
36. A data analyst
previously created a series of nested functions that carry out multiple
operations on some data in R. The analyst wants to complete the same operations
but make the code easier to understand for their stakeholders. Which of the
following can the analyst use to accomplish this?
Answers
·
Pipe
·
Comment
·
Argument
·
Vector
Explanation: The data analyst may utilize R's pipe operator (%>%) to
simplify nested function calls and make the code more easily understandable for
the people who have a stake in the project. In most cases, the magrittr or
dplyr packages are the ones that are linked with the pipe operator.
The analyst is given the flexibility to chain actions in a left-to-right sequence when they make use of the pipe operator, which improves readability and reduces the necessity for nested function calls. Workflows involving data modification and analysis benefit tremendously from its use.
37. A data analyst wants
to assign the value 50 to the variable daily_dosage. Which of the following
types of operators will they need to use in the code?
Answers
·
Relational
·
Arithmetic
·
Assignment
·
Assignment
38. A data analyst needs
to find a package that offers a consistent set of functions that help them
complete common data manipulation tasks like selecting and filtering. What
tidyverse package provides this functionality?
Answers
·
tidyr
·
readr
·
ggplot2
·
dplyr
Explanation: The
dplyr package, which is part of the tidyverse, offers a standardized collection
of functions for doing frequent data manipulation tasks such as choosing and
filtering data. Because of its user-friendly syntax and extensive data
manipulation features, the dplyr package, which is a component of the tidyverse
ecosystem, has found widespread use.
39. When programming in
R, what is a pipe used as an alternative for?
Answers
·
Nested function
·
Variable
·
Installed package
·
Vector
Explanation: In R programming, the pipe operator (%>%) may be used as
an alternative to nested function calls. This provides a mechanism to chain
actions that is both more legible and expressive. The pipe operator is often
implemented within the framework of the tidyverse, where it is connected with
the magrittr or dplyr packages and is used frequently.
The use of the pipe operator, as opposed to nesting functions, results in code that is more linear and simpler to comprehend. Use the pipe operator to link together a series of actions in a left-to-right fashion rather than creating nested function calls. Workflows involving data modification and analysis may benefit tremendously from this feature.
40. Which of the
following is a best practice when naming functions in R?
Answers
·
Function names should be capitalized
·
Function names should be
verbs
·
Function names should be very long
·
Function names should start with a
special character
Explanation: When
naming functions in R, one of the best practices is to create names that are
meaningful, descriptive, and that reflect the function's purpose. This helps
increase the readability of the code and makes it simpler for others, including
yourself, to comprehend the role that the function plays within the larger
codebase.
41. A data analyst wants
to create the date February 27th, 2027 using the lubridate functions. Which of
the following are examples of code that would create this value? Select all
that apply.
Answers
·
dmy(02272027)
·
mdy(“2027-02-27”)
·
mdy(02272027)
·
ymd(“2027-02-27”)
42. A data analyst
inputs the following code in RStudio: print(100 / 10) What type operators does
the analyst use in the code?
Answers
·
Assignment
·
Arithmetic
·
Conditional
·
Logical
Explanation: The data analyst makes use of the division operator (/) in
the code that reads "print(100 / 10)." R's division operator is a
mathematical operator that divides the value on the left side by the value on
the right side. In other words, it takes the left value and divides it by the
right value.
In this particular illustration, the division process is represented as 100 divided by 10, which yields the number 10. The result of the division operation is then shown by using the print() function, which displays the output of the division operation.
43. A data analyst wants
to store a vector in a variable. What type of operator would they use to do
this?
Answers
·
Assignment
·
Arithmetic
·
Relational
·
Logical