# Course 7 – Data Analysis with R Programming Quiz Answers

## Week 2: Programming Using Rstudio

## GOOGLE DATA ANALYTICS PROFESSIONAL CERTIFICATE

## Coursera RStudio Answers Study Guide

## Programming Using Rstudio introduction

In this part of the course, you will gain a deeper understanding of Programming Using R in RStudio. You’ll explore the main functions and variables associated with Programming Using R and learn how to use them effectively. In addition, you’ll become familiar with R packages and how to use them within the context of Programming Using R.

This knowledge is essential for earning Coursera’s** Google Data Analytics Professional Certification **as well as other industry certifications related to Programming Using R. After completing this part of the course, you should be comfortable using Programming Using R to complete your analysis efficiently and accurately.

## Learning Objectives

- Describe the contents and components of the tidyverse package for R
- Describe the concept of packages in R programming language
- Describe the use of operators to complete calculations in the R programming language
- Describe the fundamental concepts associated with programming in R including functions, variables, data types, pipes, and vectors
- Install and load the tidyverse package
- Use the browseVignettes(“packagename”) function to read through vignettes of a loaded package
- Locate resources for help using R

## Test your knowledge on programming concepts

### 1. Why do analysts use comments In R programming? Select all that apply.

- To explain their code
**(Correct)** - To provide names for variables
- To act as functions
- To make an R Script more readable
**(Correct)**

**Correct: In R programming, comments are used to explain your code and to make an R Script more readable.**

### 2. What should you use to assign a value to a variable in R?

- A vector
- An argument
- An operator
**(Correct)** - A comment

**Correct: You should use an operator to assign a value to a variable in R. You should use operators such as <- after a variable to assign a value to it.**

### 3. Which of the following examples is the proper syntax for calling a function in R?

- #first
- data_1
- <- 20
- print()
**(Correct)**

**Correct: An example of the syntax for a function in R is print(). If you add an argument in the parentheses for the print() function, the argument will appear in the console pane of RStudio.**

### 4. Which of the following examples can you use in R for date/time data? Select all that apply.

- seven-24-2018
- 2019-04-16
**(Correct)** - 06:11:13 UTC
**(Correct)** - 2018-12-21 16:35:28 UTC
**(Correct)**

**Correct: The examples of types of date/time data that you can use in R are 06:11:13 UTC, 2019-04-16, and 2018-12-21 16:35:28 UTC. R recognizes the syntax of each of these formats as a date/time data type.**

## Test your knowledge on coding in R

### 1. An analyst includes the following calculation in their R programming:

**midyear_sales <- (quarter_1_sales + quarter_2_sales) – overhead_costs**

## Which variable will the total from this calculation be assigned to?

- midyear_sales
**(Correct)** - quarter_1_sales
- quarter_2_sales
- overhead_costs

**Correct: The total from this calculation will be assigned to the variable midyear_sales. The assignment operator <- follows the variable mid_sales, so the value of the calculated total is assigned to this variable.**

### 2. An analyst is checking the value of the variable x using a logical operator, so they run the following code:

** x > 35 & x < 65**

### Which values of x would return TRUE when the analyst runs the code? Select all that apply.

- 35
- 50
**(Correct)** - 60
**(Correct)** - 70

**Correct: The values 50 and 60 will return TRUE when the analyst runs the code x > 35 & x < 65. In this code, the logical operator & tells the server to return TRUE when the value of the variable is greater than 35 and less than 65.**

### 3. A data analyst inputs the following code in RStudio:

**sales_1 <- 100 * sales_2**

### Which of the following types of operators does the analyst use in the code? Select all the apply.

- relational
- assignment
- arithmetic
**(Correct)** - logical
**(Correct)**

**Correct: The analyst uses assignment and arithmetic operators in the code. The assignment operator (<-) assigns the variable sales_1 to the value of 100 * sales_2. The multiplication operator (*) multiplies 100 by sales_2.**

## test your knowledge on R packages

### 1. When using RStudio, what does the installed.packages() function do?

- Creates code for analysts to use to edit their packages
- Installs all available packages for use in an RStudio session
- Selects the best packages to use based on an analyst’s current needs
- Presents a list of packages currently installed in an RStudio session
**(Correct)**

**Correct: The installed.packages() function shows a list of packages currently installed in an RStudio session. You can then locate the names of the packages and what’s needed to use functions from the package.**

### 2. In data analytics, what is CRAN?

- A commonly used online archive with R packages and other R resources
**(Correct)** - An R interface that has many of the same functions as RStudio
- A function for finding packages to use for analysis in RStudio
- A collection of packages that function together to make analysis in R more efficient

**Correct: CRAN is a commonly used online archive with R packages and other R resources. CRAN makes sure that the R resources it shares follow the required quality standards and are authentic and valid.**

### 3. What are ggplot2, tidyr, dplyr, and forcats all a part of?

- A list of functions that clean data efficiently
- A collection of core tidyverse packages
**(Correct)** - A list of variables for use in programming in RStudio
- A collection of commonly used, CRAN-based data sets

**Correct: The packages ggplot2, tidyr, dplyr, and forcats are part of a collection of eight core tidyverse packages. The other core packages are: tibble, readr, purrr, and stringr.**

## Test your knowledge on the tidyverse

### 1. When working in R, for which part of the data analysis process do analysts use the tidyr package?

- Data cleaning
**(Correct)** - Data security
- Data calculations
- Data visualization

**Correct: Analysts use the tidyr package for data cleaning. It works with wide and long data to make sure every part of a data table or data frame is the right data type and in the right place.**

### 2. Which tidyverse package contains a set of functions, such as select(), that help with data manipulation?

- ggplot2
- dplyr
**(Correct)** - readr
- forcats

**Correct: The dplyr package is the tidyverse package which contains a set of functions, such as select(), that help with data manipulation. For example, select() selects only relevant variables based on their names.**

### 3. An analyst is organizing a dataset in RStudio using the following code:

**arrange(filter(Storage_1, inventory >= 40), count)**

### Which of the following examples is a nested function in the code?

- inventory
- filter
**(Correct)** - count
- arrange

**Correct: In the analyst’s code, filter is the nested function. It is embedded in the argument of the broader arrange function.**

## GOOGLE DATA ANALYTICS COURSERA ANSWERS AND STUDY GUIDE

**Liking our content? Then don’t forget to add us to your bookmarks so you can find us easily!**

Weekly Breakdown | Google Study Guides | Back to Top

## Data Analysis with R Programming Weekly Challenge 2

### 1. Which of the following are examples of variable names that can be used in R? Select all that apply.

- utility2
**(Correct)** - 3_sales
- _red_1
- autos_5
**(Correct)**

**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.**

### 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?

- v(12, 23, 51)
- c(12, 23, 51)
**(Correct)** - v(51, 23, 12)
- c(51, 23, 12)

**Correct: The code chunk c(12, 23, 51) allows you to create a vector with the values 12, 23, 51. 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.**

### 3. 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?

- now()
- lubridate()
- datetime()
- mdy()
**(Correct)**

**Correct: To convert the strings to date/time data types, the analyst should use the function mdy(). The mdy() function and other variations of the ymd() function convert string dates and times into date/time data types that are compatible with R.**

### 4. A data analyst inputs the following code in RStudio:

**sales_1 <- (3500.00 * 12)**

### Which of the following types of operators does the analyst use in the code? Select all that apply.

- Logical
- Relational
- Arithmetic
**(Correct)** - Assignment
**(Correct)**

**Correct: In the code sales_1 <- (3500.00 * 12), the analyst uses an assignment (<-) and an arithmetic (*) operator. The assignment operator assigns the calculated value in parentheses to the variable sales_1 and the arithmetic operator multiplies the values in parentheses to complete the calculation.**

### 5. Which of the following files in R have names that follow widely accepted naming convention rules? Select all that apply.

- patient_details_1.R
**(Correct)** - patient_data.R
**(Correct)** - p1+infoonpatients.R
- title*123.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.**

### 6. In R, what includes reusable functions and documentation about how to use the functions?

- Vectors
- Packages
**(Correct)** - Pipes
- Comments

**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.**

### 7. Packages installed in RStudio are called from CRAN. CRAN is an online archive with R packages and other R-related resources.

- True
**(Correct)** - False

**Correct: Packages installed in RStudio are called from CRAN. CRAN is an online archive with R packages and other R-related resources.**

### 8. A data analyst is reviewing some code and finds the following code chunk:

### What is this code chunk an example of?

- Pipe
**(Correct)** - Vector
- Nested function
- Data frame

**Correct: The code chunk is an example of a pipe. A pipe is a tool for expressing a sequence of multiple operations in R (in this case filtering and grouping). The operator for a pipe is %>%.**

## Programming Using Rstudio INTRODUCTION

With R, you’ll be able to complete your analysis more efficiently and effectively. After taking this part of the course, you will have explored the fundamental concepts associated with R. You will understand functions and variables for calculations and other programming.

In addition, you should discover R packages, collections of R functions that are often used together. With all these tools at your disposal, consider joining the learning experience in** Coursera** today!

#### Subscribe to our site

Get new content delivered directly to your inbox.

## Quiztudy Top Courses

## Popular in Coursera

- Meta Marketing Analytics Professional Certificate.
- Google Digital Marketing & E-commerce Professional Certificate.
- Google UX Design Professional Certificate.
- Meta Social Media Marketing Professional Certificate
- Google Project Management Professional Certificate
- Meta Front-End Developer Professional Certificate

**Liking our content? Then, don’t forget to ad us to your BOOKMARKS so you can find us easily!**