7.2.3.Weekly challenge 2 - sj50179/Google-Data-Analytics-Professional-Certificate GitHub Wiki
Weekly challenge 2
LATEST SUBMISSION GRADE 100%
Question 1
Which of the following are examples of variable names that can be used in R? Select all that apply.
- autos_5
_red_13_sales- utility2
Correct. Examples of variable names that can be used in R are autos_5 and utility2. Variable names should start with a letter and can also contain numbers and underscores.
Question 2
You want to create a vector with the values 43, 56, 12 in that exact order. After specifying the variable, what R code chunk allows you to create this vector?
c(43, 56, 12)
v(43, 56, 12)
v(12, 56, 43)
c(12, 56, 43)
Correct. The code chunk *c(43, 56, 12)
*** will create a vector with the values 43, 56, 12. A vector is a group of data elements of the same type stored in a sequence in R. You can create a vector by putting the values you want inside the parentheses of the combine function.
Question 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.
ymd(20200710)
mdy(“July 10th, 2020”)
myd(2020, July 10)
dmy(“7-10-2020”)
Correct. The code that would lead to the value of “2020-07-10” are ymd(20200710)
and mdy("July 10th, 2020")
*. Both of these code chunks use the date/time functions that convert string data types to date/time data types.*
Question 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?
- Assignment
ArithmeticLogicalRelational
Correct. In this code, the analyst uses an assignment operator: <-. The assignment operator assigns the value 70 to the variable change_1
*.*
Question 5
Which of the following files in R have names that follow widely accepted naming convention rules? Select all that apply.
title*123.R- patient_data.R
- patient_details_1.R
p1+infoonpatients.R
Correct. The files with names that follow widely accepted naming convention rules are patient_data.R and patient_details_1.R. These file names end in .R and use only lowercase letters, numbers, and underscores. They are also clear, concise, and meaningful.
Question 6
In R, what includes reusable functions and documentation about how to use the functions?
VectorsComments- Packages
Pipes
Correct. In R, packages include reusable R functions and documentation about how to use the functions. They also include sample data sets and tests for checking your code.
Question 7
When an analyst installs a package that is not in Base R, where does R call the package from?
The RStudio websiteThe tidyversePython- The CRAN archive
Correct. When an analyst installs a package that is not in Base R, R calls the package from the CRAN archive. CRAN is an online archive with R packages and other R-related resources.
Question 8
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?
- Pipe
- Vector
- Comment
- Argument
Correct. The analyst can create a pipe. A pipe is a tool for expressing a sequence of multiple operations in R, which can make the operations easier to understand for analysts and stakeholders.