week 1 quiz

Ace your homework & exams now with Quizwiz!

Functions (R)

A body of reusable code used to perform specific tasks in R

Nested function

A function that is completely contained within another function

A nested function is a function contained within code that performs a broader function.

A nested function is a function contained within code that performs a broader function. The nested function performs its own specific function within the code.

tidyr (R)

A package used for data cleaning to make tidy data

When programming in R, what is a pipe used as an alternative for?

A pipe can be used as an alternative for a nested function. You can use both pipes and nested functions to complete multiple operations on data. However, a pipe is often the preferred method because it makes your code easier to read and understand.

Variable (R)

A representation of a value in R that can be stored for use later during programing

Tidyverse (R)

A system of packages in R with a common design philosophy for data manipulation, exploration, and visualization

Pipe (R)

A tool in R for expressing a sequence of multiple operations, represented with "%>%

In R, a variable name should begin with a number or an underscore.

A variable name can contain numbers and underscores, but it should begin with a letter.

When using pipes:

Add the pipe operator at the end of each line of the piped operation except the last one

Question 3 Which of the following examples is the proper syntax for a function in R?

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

CRAN (Comprehensive R Archive Network) (R)

An online archive with R packages, source code manuals, and documentation

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

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.

In data analytics, what is CRAN?

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.

ggplot2(R)

Create a variety of data viz by applying different visual properties to the data variables in R

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

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.

The basic concepts of R

Functions Comments Variables Data types Vectors Pipes

If you use the mdy() function in R to convert the string "April 10, 2019", what will return when you run your code?

If you use the mdy() function in R to convert the string "April 10, 2019", the value returned will be "2019-04-10". The mdy() function and other variations of the ymd() function convert string data types into date/time data types.

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

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

Fill in the blank: In R, the _____ is information that a function needs to run

In R, the argument is information that a function needs to run

A data analyst writes the code summary(penguins) in order to show a summary of the penguins dataset. Where in RStudio can the analyst execute the code? Select all that apply. 1 / 1 point

In RStudio, the analyst can execute the code in both the R console pane and the source editor pane.

Nested

In programing, describes code that performs a particular function and is contained within code that performs a broader function

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?

In the analyst's code, filter is the nested function. It is embedded in the argument of the broader arrange function.

Argument (R)

Information that a function in R needs in order to run

Many data analysts prefer to use a programming language for which of the following reasons? Select all that apply.

Many data analysts prefer to use a programming language in order to easily reproduce and share an analysis, save time, and clarify the steps of an analysis.

dplyr (R)

Offers a consistent set of functions that help you complete some common data manipulation tasks

What is the term for programming code that is freely available and may be modified and shared by the people who use it?

Open-source code is freely available and may be modified and shared by the people who use it.

Fill in the blank: Packages in R include _____. Select all that apply.

Packages in R include reusable R functions, documentation about how to use the functions, sample datasets, and tests for checking your code.

A data analyst uses words and symbols to give instructions to a computer. What are the words and symbols known as?

Programming languages are the words and symbols you use to write instructions for computers to follow.

Which of the following are included in R packages? Select all that apply.

R packages include reusable R functions, sample datasets, and tests for checking your code. R packages also include documentation about how to use the included functions.

RStudio's integrated development environment lets you perform which of the following actions? Select all that apply.

RStudio's integrated development environment lets you install R packages, import data from spreadsheets, and create data visualizations.

Packages include:

Reusable R functions Documentation about the functions Sample datasets Tests fir checking your code

A data analyst is working with spreadsheet data. The analyst imports the data from the spreadsheet into RStudio. Where in RStudio can the analyst find the imported data?

The analyst can find the imported data in the environment pane. The environment pane displays data that is currently loaded in RStudio.

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 write that code?

The analyst can use an assignment operator to write the following code: daily_dosage <- 50. In this code, the assignment operator <- is used to assign a value of 50 to the variable daily_dosage.

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.

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.

Fill in the blank: The benefits of using _____ for data analysis include the ability to quickly process lots of data and create high quality visualizations.

The benefits of using the R programming language for data analysis include the ability to quickly process lots of data and create high quality visualizations.

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

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.

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

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.

Which tidyverse package is used for data visualization?

The ggplot2 package is used for data visualization, specifically plots. You can use ggplot2 to create a lot of different visualizations by applying different properties to the data variables.

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

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.

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

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.

Which of the following operators is the pipe operator?

The pipe operator is %>%. You can use it in R programming to call out a pipe to express a sequence of multiple operations.

The read_csv() function is a part of the dplyr package.

The read_csv() function is a part of the readr package. It imports a .CSV file for use in R.

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?

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.

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.

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.

Which of the following variables have names that follow widely accepted naming convention rules? Select all that apply.

The variables with a name that follows widely accepted naming convention rules are total_plums and plum_total_1. These variable names use only lowercase letters and underscores and are clear, concise, and meaningful.

Tidyverse is a collection of packages in R with a common design philosophy.

Tidyverse is a collection of packages in R with a common design philosophy. The tidyverse packages are especially useful for data manipulation, exploration, and visualization.

Packages (R)

Units of reproducible R code

readr (R)

Used for importing data

Assignment operators

Used to assign values to variables and vectors

Arithmetic operators

Used to complete math calculations

When an analyst installs a package that is not in Base R, where does R call the package from?

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.

What should you use to assign a value to a variable in R

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.

Which function can you use to create a different plot for each type of cut of diamond? 1 / 1 point

facet_wrap() is an R function used to create subplots, which are individual plots that represent a specific part of a broader dataset. In upcoming activities, you will learn more functions that are helpful while programming in R.

Four packages that are an essential part of the workflow for data analysts:

ggplot2 dplyr tidyr readr

8 core tidyverse packages

ggplot2 tidyr readr dplyr tibble purrr stringr forcats


Related study sets

CCJ1010 Midterm Study Guide, Chapters 1-8

View Set

Series 6 Unit 3 NEED TO KNOW TERMS

View Set

Exam 3 (Final) Powerpoint Questions

View Set

Chapter 5 Time Value of Money Concepts Intermediate Accounting 1

View Set

IT-1430 Exam 1 Review - Tutorial 4 - Graphic Design with CSS

View Set

History 102 - Midterm Study Guide

View Set