PRACTICE QUIZ
Your team already uses R. Why might they benefit from adopting R Markdown? Select all that apply.
A data analyst wants to change their header to be one font size smaller. What should they add to their markdown syntax?
A data analyst wants to include a line of code directly in their .rmd file in order to explain their process more clearly. What is this code called?
What symbol can be used to add bullet points in R Markdown?
Which sample correctly implements a code chunk in a .rmd file? value <- 8 ``` value <- 8 ``` (CORRECT) value <- 8 --- value <- 8 ###
Why would a data analyst create a template of their .rmd file? Select all that apply.
A data analyst wants to create documentation for their cleaning process so other analysts on their team can recreate this process. What tool can help them create this shareable report?
Fill in the blank: R Markdown notebooks can be converted into HTML, PDF, and Word documents, slide presentations, and _____.
A data analyst writes two hashtags next to their header. What will this do to the header font in the .rmd file?
Which pieces of markdown text will produce a result that is italicized? Select all that apply.
A data analyst includes a code chunk in their .rmd file. What does this allow other users to do? Select all that apply.
A data analyst who works with R creates a weekly sales report by remaking their .rmd file and converting it to a report. What can they do to streamline this process?
What are the benefits of working with R Markdown? Select all that apply.
A data analyst finishes editing an R Markdown notebook and wants to convert it to a new format they can share. What are their options? Select all that apply.
Which code snippet implements the correct syntax for writing a piece of hyperlinked text in markdown?
A data analyst wants to make a word in their markdown stand out by making it bold. What characters should they surround the text with to achieve the bold style?
R Markdown is a file format for making dynamic documents with R. What are the benefits of creating this kind of document? Select all that apply.
A data analyst wants to export their R Markdown notebook as a text document. What are the text document formats they can use to share their R Markdown notebook? Select all that apply.
Which combination of text characters can be used to embed an image in a markdown document?
What is the purpose of the Knit button in R Studio?
A data analyst adds a section of executable code to their .rmd file so users can execute it and generate the correct output. What is this section of code called?
A data analyst is inserting a line of code directly into their .rmd file. What will they use to mark the beginning and end of the code?
Fill in the blank: If an analyst creates the same kind of document over and over or customizes the appearance of a final report, they can use _____ to save them time.
A data analyst wants to change the default file format that gets exported by the Knit button to .pdf. What field of the YAML header should they change to set the new default file format?
When you Knit a file in RStudio what part of code chunks are shown by default?
A data analyst inputs asterisks before a word of phrase in R Markdown. How will this appear in the document?
Fill in the blank: Code added to an .rmd file is usually referred to as a code _____. This allows users to execute R code from within the .rmd file.
A data analyst adds specific characters before and after their code chunk to mark where the data item begins and ends in the .rmd file. What are these characters called?
A data analyst wants to perform an analysis and make it easy for colleagues to understand his process and update the analysis a year from now. Which tool is best to achieve this objective?
What does the ```{r} delimiter (three backticks followed by an r contained inside curly brackets) indicate in an R Markdown notebook? COURSE CHALLENGE
Scenario 1, questions 1-7 As part of the data science team at Gourmet Analytics, you use data analytics to advise companies in the food industry. You clean, organize, and visualize data to arrive at insights that will benefit your clients. As a member of a collaborative team, sharing your analysis with others is an important part of your job. Your current client is Chocolate and Tea, an up-and-coming chain of cafes. ( Image S2Q1 ) The eatery combines an extensive menu of fine teas with chocolate bars from around the world. Their diverse selection includes everything from plantain milk chocolate, to tangerine white chocolate, to dark chocolate with pistachio and fig. The encyclopedic list of chocolate bars is the basis of Chocolate and Tea’s brand appeal. Chocolate bar sales are the main driver of revenue. Chocolate and Tea aims to serve chocolate bars that are highly rated by professional critics. They also continually adjust the menu to make sure it reflects the global diversity of chocolate production. The management team regularly updates the chocolate bar list in order to align with the latest ratings and to ensure that the list contains bars from a variety of countries. They’ve asked you to collect and analyze data on the latest chocolate ratings. In particular, they’d like to know which countries produce the highest-rated bars of super dark chocolate (a high percentage of cocoa). This data will help them create their next chocolate bar menu. Your team has received a dataset that features the latest ratings for thousands of chocolates from around the world. Click here to access the dataset. Given the data and the nature of the work you will do for your client, your team agrees to use R for this project. Your supervisor asks you to write a short summary of the benefits of using R for the project. Which of the following benefits would you include in your summary? Select all that apply.
The benefits of using R for the project include the ability to quickly process lots of data and create high-quality data visualizations. You can also easily reproduce and share your analysis.
Scenario 1, continued Before you begin working with your data, you need to import it and save it as a data frame. To get started, you open your RStudio workspace and load the tidyverse library. You upload a .csv file containing the data to RStudio and store it in a project folder named flavors_of_cacao.csv. You use the read_csv() function to import the data from the .csv file. Assume that the name of the data frame is chocolate_df and the .csv file is in the working directory. What code chunk lets you create the data frame? Explanation : The code chunk chocolate_df <-read_csv("flavors_of_cacao.csv") lets you create the data frame. In this code chunk: chocolate_df is the name of the data frame that will store the data. <- is the assignment operator to assign values to the data frame. read_csv() is the function that will import the data to the data frame. "flavors_of_cacao.csv" is the file name that read.csv() function takes for its argument.
Scenario 1, continued Now that you’ve created a data frame, you want to find out more about how the data is organized. The data frame has hundreds of rows and lots of columns. Assume the name of your data frame is flavors_df. What code chunk lets you review the column names in the data frame?
You write the code chunk colnames(flavors_df). In this code chunk: colnames() is the function that will let you review the column names in the data frame. flavors_df is the name of the data frame that the colnames() function takes for its argument.
Scenario 2, continued A teammate creates a new plot based on the chocolate bar data. The teammate asks you to make some revisions to their code. Assume your teammate shares the following code chunk: ggplot(data = best_trimmed_flavors_df) + geom_bar(mapping = aes(x = Rating)) + What code chunk do you add to the third line to create wrap around facets of the variable Rating?
You write the code chunk facet_wrap(~Rating). In this code chunk: facet_wrap() is the function that lets you create wrap around facets of a variable. Inside the parentheses of the facet_wrap() function, type a tilde symbol (~) followed by the name of the variable (Rating).
Scenario 2, continued Your team has created some basic visualizations to explore different aspects of the chocolate bar data. You’ve volunteered to add titles to the plots. You begin with a scatterplot. Assume the first part of your code chunk is: ggplot(data = trimmed_flavors_df) + geom_point(mapping = aes(x = Cocoa.Percent, y = Rating)) + What code chunk do you add to the third line to add the title Best Chocolates to your plot?
You write the code chunk labs(title = “Best Chocolates”). In this code chunk: labs() is the function that lets you add a title to your plot. In the parentheses of the labs() function, write the word title, then an equals sign, then the specific text of the title in quotation marks (“Best Chocolates”).
Scenario 2, continued Next, you create a new scatterplot to explore the relationship between different variables. You want to save your plot so you can access it later on. You know that the ggsave() function defaults to saving the last plot that you displayed in RStudio, so you’re ready to write the code to save your scatterplot. Assume your first two lines of code are: ggplot(data = trimmed_flavors_df) + geom_point(mapping = aes(x = Cocoa.Percent, y = Rating)) + What code chunk do you add to the third line to save your plot as a jpeg file with chocolate as the file name?
You add the code chunk ggsave(“chocolate.jpeg”) to save your plot as a jpeg file with “chocolate” as the file name. In this code chunk: Inside the parentheses of the ggsave() function, type a quotation mark followed by the file name (chocolate), then a period, then the type of file format (jpeg), then a closing quotation mark.
Scenario 2, continued As a final step in the analysis process, you create a report to document and share your work. Before you share your work with the management team at Chocolate and Tea, you are going to meet with your team and get feedback. Your team wants the documentation to include all your code and display all your visualizations. Fill in the blank: You want to record and share every step of your analysis, let teammates run your code, and display your visualizations. You decide to create _____ to document your work.
You use an R Markdown notebook to document your work. The notebook lets you record and share every step of your analysis, lets your teammates run your code, and displays your visualizations.
Scenario 2, continued A teammate creates a new plot based on the chocolate bar data. The teammate asks you to make some revisions to their code. Assume your teammate shares the following code chunk: ggplot(data = best_trimmed_flavors_df) + geom_bar(mapping = aes(x = Cocoa.Percent)) + What code chunk do you add to the third line to create wrap around facets of the variable Cocoa.Percent?
You write the code chunk facet_wrap(~Cocoa.Percent). In this code chunk: facet_wrap() is the function that lets you create wrap around facets of a variable. Inside the parentheses of the facet_wrap() function, type a tilde symbol (~) followed by the name of the variable (Cocoa.Percent).
Scenario 2, continued Your team has created some basic visualizations to explore different aspects of the chocolate bar data. You’ve volunteered to add titles to the plots. You begin with a scatterplot. Assume the first part of your code chunk is: ggplot(data = trimmed_flavors_df) + geom_point(mapping = aes(x = Cocoa.Percent, y = Rating)) + What code chunk do you add to the third line to add the title Suggested Chocolate to your plot?
You write the code chunk labs(title = “Suggested Chocolate”). In this code chunk: labs() is the function that lets you add a title to your plot. In the parentheses of the labs() function, write the word title, then an equals sign, then the specific text of the title in quotation marks (“Suggested Chocolate”).
Scenario 2, continued Next, you create a new scatterplot to explore the relationship between different variables. You want to save your plot so you can access it later on. You know that the ggsave() function defaults to saving the last plot that you displayed in RStudio, so you’re ready to write the code to save your scatterplot. Assume your first two lines of code are: ggplot(data = trimmed_flavors_df) + geom_point(mapping = aes(x = Cocoa.Percent, y = Rating)) What code chunk do you add to the third line to save your plot as a png file with chocolate as the file name?
You write the code chunk ggsave(“chocolate.png”). In this code chunk: Inside the parentheses of the ggsave() function, type a quotation mark followed by the file name (chocolate), then a period, then the type of file format (png), then a closing quotation mark
Scenario 1, questions 1-7 As part of the data science team at Gourmet Analytics, you use data analytics to advise companies in the food industry. You clean, organize, and visualize data to arrive at insights that will benefit your clients. As a member of a collaborative team, sharing your analysis with others is an important part of your job. Your current client is Chocolate and Tea, an up-and-coming chain of cafes. ( Image S2Q11 ) The eatery combines an extensive menu of fine teas with chocolate bars from around the world. Their diverse selection includes everything from plantain milk chocolate, to tangerine white chocolate, to dark chocolate with pistachio and fig. The encyclopedic list of chocolate bars is the basis of Chocolate and Tea’s brand appeal. Chocolate bar sales are the main driver of revenue. Chocolate and Tea aims to serve chocolate bars that are highly rated by professional critics. They also continually adjust the menu to make sure it reflects the global diversity of chocolate production. The management team regularly updates the chocolate bar list in order to align with the latest ratings and to ensure that the list contains bars from a variety of countries. They’ve asked you to collect and analyze data on the latest chocolate ratings. In particular, they’d like to know which countries produce the highest-rated bars of super dark chocolate (a high percentage of cocoa). This data will help them create their next chocolate bar menu. Your team has received a dataset that features the latest ratings for thousands of chocolates from around the world. Click here to access the dataset. Given the data and the nature of the work you will do for your client, your team agrees to use R for this project. A teammate asks you about the benefits of using R for the project. You mention that R can quickly process lots of data and create high quality data visualizations. What is another benefit of using R for the project?
Another benefit of using R for the project is that it can easily reproduce and share an analysis.
Scenario 1, continued Now that you’ve created a data frame, you want to find out more about how the data is organized. The data frame has hundreds of rows and lots of columns. Assume the name of your data frame is flavors_df. What code chunk lets you review the structure of the data frame?
You write the code chunk str(flavors_df). In this code chunk: str() is the function that will return the structure of the data frame, and give you high-level information like the column names and the type of data contained in those columns. flavors_df is the name of the data frame that the str() function takes for its argument.
Scenario 1, continued Next, you begin to clean your data. When you check out the column headings in your data frame you notice that the first column is named Company...Maker.if.known. (Note: The period after known is part of the variable name.) For the sake of clarity and consistency, you decide to rename this column Maker (without a period at the end). Assume the first part of your code chunk is: flavors_df %>% What code chunk do you add to change the column name?
You write the code chunk rename(Maker = Company...Maker.if.known.). In this code chunk: rename() is the function that will change the name of your column. Inside the parentheses of the function, write the new name (Maker), then an equal sign, then the name you want to change (Company...Maker.if.known.).
Scenario 2, continued As a final step in the analysis process, you create a report to document and share your work. Before you share your work with the management team at Chocolate and Tea, you are going to meet with your team and get feedback. Your team wants the documentation to include all your code and display all your visualizations. You decide to create an R Markdown notebook to document your work. What are your reasons for choosing an R Markdown notebook? Select all that apply.
You choose an R Markdown notebook to document your work because it lets you record and share every step of your analysis. The notebook allows users to run your code and also displays your data visualizations.
Scenario 1, continued Now that you’ve created a data frame, you want to find out more about how the data is organized. The data frame has hundreds of rows and lots of columns. Assume the name of your data frame is flavors_df. What code chunk lets you get a glimpse of the contents of the data frame?
You write the code chunk glimpse(flavors_df). In this code chunk: glimpse() is the function that will give you a glimpse of the contents of the data frame, and give you high-level information like column names and the type of data contained in those columns. flavors_df is the name of the data frame that the glimpse() function takes for its argument.
You finish working with an R Markdown notebook and now you need to distribute your work. How can you export your analysis as a styled report?
Fill in the blank: A delimiter is a character that indicates the beginning or end of _____.
A data analyst wants to change the default file format that gets exported by the Knit button in RStudio. Where should they change the output format?
What delimiter is used to indicate the YAML metadata in an R Markdown notebook?
What type of export document should you use while you are working and don’t need to worry about adding page breaks in the correct places?
A data analyst wants to create a shareable report of their analysis with documentation of their process and notes explaining their code to stakeholders. What tool can they use to generate this?
Fill in the blank: A data analyst includes _____ in their R Markdown notebook so that they can refer to it directly in their explanation of their analysis.
A data analyst wants to add a bulleted list to their R Markdown document. What symbol can they type to create this formatting?
A data analyst is working in a .rmd file and comes across the text ```{r analysis}. What is the purpose of the text “analysis”?
What does the --- delimiter (three hyphens) indicate in an R Markdown notebook?
A data analyst is regularly exporting documents from a .rmd file and manually customizing the appearance of the document they give to stakeholders. What would allow them to automatically customize the appearance of the document?
A data analyst notices that their header is much smaller than they wanted it to be. What happened?
A data analyst works with an .rmd file in RStudio and wants the ability to quickly find a code chunk using the label “analysis”. Which code example would allow the analyst to quickly access the code chunk using this label?
Scenario 1, questions 1-7 As part of the data science team at Gourmet Analytics, you use data analytics to advise companies in the food industry. You clean, organize, and visualize data to arrive at insights that will benefit your clients. As a member of a collaborative team, sharing your analysis with others is an important part of your job. Your current client is Chocolate and Tea, an up-and-coming chain of cafes. ( Image S4Q1 ) The eatery combines an extensive menu of fine teas with chocolate bars from around the world. Their diverse selection includes everything from plantain milk chocolate, to tangerine white chocolate, to dark chocolate with pistachio and fig. The encyclopedic list of chocolate bars is the basis of Chocolate and Tea’s brand appeal. Chocolate bar sales are the main driver of revenue. Chocolate and Tea aims to serve chocolate bars that are highly rated by professional critics. They also continually adjust the menu to make sure it reflects the global diversity of chocolate production. The management team regularly updates the chocolate bar list in order to align with the latest ratings and to ensure that the list contains bars from a variety of countries. They’ve asked you to collect and analyze data on the latest chocolate ratings. In particular, they’d like to know which countries produce the highest-rated bars of super dark chocolate (a high percentage of cocoa). This data will help them create their next chocolate bar menu. Your team has received a dataset that features the latest ratings for thousands of chocolates from around the world. Click here to access the dataset. Given the data and the nature of the work you will do for your client, your team agrees to use R for this project. You create a short document about the benefits of using R for the project and share the document with your team. You write that the benefits include R’s ability to quickly process lots of data and easily reproduce and share an analysis. What is another benefit of using R for the project?
Another benefit of using R for the project is R’s ability to create high-quality data visualizations.
Scenario 1, continued Before you begin working with your data, you need to import it and save it as a data frame. To get started, you open your RStudio workspace and load all the necessary libraries and packages. You upload a .csv file containing the data to RStudio and store it in a project folder named flavors_of_cacao.csv. You use the read_csv() function to import the data from the .csv file. Assume that the name of the data frame is flavors_df and the .csv file is in the working directory. What code chunk lets you create the data frame?
The code chunk: flavors_df <- read_csv("flavors_of_cacao.csv") lets you create the data frame. In this code chunk: flavors_df is the name of the data frame that will store the data. <- is the assignment operator to assign values to the data frame. read_csv() is the function that will import the data to the data frame. "flavors_of_cacao.csv" is the file name that read.csv() function takes for its argument.
After previewing and cleaning your data, you determine what variables are most relevant to your analysis. Your main focus is on Rating, Cocoa.Percent, and Company. You decide to use the select() function to create a new data frame with only these three variables. Assume the first part of your code is: trimmed_flavors_df <- flavors_df %>% Add the code chunk that lets you select the three variables. 1 What company appears in row 1 of your tibble?
You add the code chunk select(Rating, Cocoa.Percent, Company) to select the three variables. The correct code is trimmed_flavors_df <- flavors_df %>% select(Rating, Cocoa.Percent, Company). In this code chunk: The select() function lets you select specific variables for your new data frame. select() takes the names of the variables you want to choose as its argument: Rating, Cocoa.Percent, Company. The company A. Morin appears in row 1 of your tibble.
Next, you select the basic statistics that can help your team better understand the ratings system in your data. Assume the first part of your code is: trimmed_flavors_df %>% You want to use the summarize() and mean() functions to find the mean rating for your data. Add the code chunk that lets you find the mean value for the variable Rating. 1 Run Reset What is the mean rating?
You add the code chunk summarize(mean(Rating)) to find the mean value for the variable Rating. The correct code is trimmed_flavors_df %>% summarize(mean(Rating)). In this code chunk: The summarize() function lets you display summary statistics. You can use the summarize() function in combination with other functions such as mean(), sd(), and max() to calculate specific statistics. In this case, you use mean() to calculate the mean value for the variable Rating. The mean rating is 3.185933.
After completing your analysis of the rating system, you determine that any rating greater than or equal to 3.9 points can be considered a high rating. You also know that Chocolate and Tea considers a bar to be super dark chocolate if the bar's cocoa percent is greater than or equal to 75%. You decide to create a new data frame to find out which chocolate bars meet these two conditions. Assume the first part of your code is: best_trimmed_flavors_df <- trimmed_flavors_df %>% You want to apply the filter() function to the variables Cocoa.Percent and Rating. Add the code chunk that lets you filter the data frame for chocolate bars that contain at least 75% cocoa and have a rating of at least 3.9 points. 1 What value for cocoa percent appears in row 1 of your tibble?
The code chunk filter(Cocoa.Percent >= 75, Rating >= 3.9) lets you filter the data frame for chocolate bars that contain at least 75% cocoa and have a rating of at least 3.9 points. The correct code is best_trimmed_flavors_df <- trimmed_flavors_df %>% filter(Cocoa.Percent >= 75, Rating >= 3.9). In this code chunk: The filter() function lets you filter your data frame based on specific criteria. Cocoa.Percent and Rating refer to the variables you want to filter. The >= operator signifies “greater than or equal to.” The new data frame will show all the values of Cocoa.Percent greater than or equal to 75, and all the values of Rating greater than or equal to 3.9. The value 75% for cocoa percent appears in row 1 of your tibble.
Now that you’ve cleaned and organized your data, you’re ready to create some useful data visualizations. Your team assigns you the task of creating a series of visualizations based on requests from the Chocolate and Tea management team. You decide to use ggplot2 to create your visuals. Assume your first line of code is: ggplot(data = best_trimmed_flavors_df) + You want to use the geom_bar() function to create a bar chart. Add the code chunk that lets you create a bar chart with the variable Rating on the x-axis. 1 How many bars does your bar chart display?
You add the code chunk geom_bar(mapping = aes(x = Rating)) to create a bar chart with the variable Rating on the x-axis. The correct code is ggplot(data = best_trimmed_flavors_df) + geom_bar(mapping = aes(x = Rating)). In this code chunk: geom_bar() is the geom function that uses bars to create a bar chart. Inside the parentheses of the aes() function, the code x = Rating maps the x aesthetic to the variable Rating. Rating will appear on the x-axis of the plot. By default, R will put a count of the variable Rating on the y-axis. Your bar chart displays 2 bars.
Your bar chart reveals the locations that produce the highest rated chocolate bars. To get a better idea of the specific rating for each location, you’d like to highlight each bar. Assume that you are working with the code chunk: ggplot(data = best_trimmed_flavors_df) + geom_bar(mapping = aes(x = Company.Location)) Add a code chunk to the second line of code to map the aesthetic color to the variable Rating. NOTE: the three dots (...) indicate where to add the code chunk. 1 geom_bar(mapping = aes(x = Company.Location, ...)) According to your bar chart, which two company locations produce the highest rated chocolate bars?
You add the code chunk color = Rating to the second line of code to map the aesthetic color to the variable Rating. The correct code is ggplot(data = best_trimmed_flavors_df) + geom_bar(mapping = aes(x = Company.Location, color = Rating)). In this code chunk: Inside the parentheses of the aes() function, after the comma that follows x = Company.Location, write the aesthetic (color), then an equals sign, then the variable (Rating). The specific rating of each location will appear as a specific color that outlines each bar of your bar chart. On your visualization, the legend titled "Rating" shows the color coding for the variable Rating. Lighter blues correspond to higher ratings and darker blues correspond to lower ratings. According to your bar chart, the two company locations that produce the highest rated chocolate bars are Canada and France.
Scenario 2, continued A teammate creates a new plot based on the chocolate bar data. The teammate asks you to make some revisions to their code. Assume your teammate shares the following code chunk: ggplot(data = best_trimmed_flavors_df) + geom_bar(mapping = aes(x = Company)) + What code chunk do you add to the third line to create wrap around facets of the variable Company?
You write the code chunk facet_wrap(~Company). In this code chunk: facet_wrap() is the function that lets you create wrap around facets of a variable. Inside the parentheses of the facet_wrap() function, type a tilde symbol (~) followed by the name of the variable (Company).
Scenario 2, continued Your team has created some basic visualizations to explore different aspects of the chocolate bar data. You’ve volunteered to add titles to the plots. You begin with a scatterplot. Assume the first part of your code chunk is: ggplot(data = trimmed_flavors_df) + geom_point(mapping = aes(x = Cocoa.Percent, y = Rating)) + What code chunk do you add to the third line to add the title Recommended Bars to your plot?
You write the code chunk labs(title = “Recommended Bars”). In this code chunk: labs() is the function that lets you add a title to your plot. In the parentheses of the labs() function, write the word title, then an equals sign, then the specific text of the title in quotation marks (“Recommended Bars”).
Scenario 1, continued Before you begin working with your data, you need to import it and save it as a data frame. To get started, you open your RStudio workspace and load the tidyverse library. You upload a .csv file containing the data to RStudio and store it in a project folder named flavors_of_cacao.csv. You use the read_csv() function to import the data from the .csv file. Assume that the name of the data frame is bars_df and the .csv file is in the working directory. What code chunk lets you create the data frame?
The code chunk bars_df <- read_csv("flavors_of_cacao.csv") lets you create the data frame. In this code chunk: bars_df is the name of the data frame that will store the data. <- is the assignment operator to assign values to the data frame. read_csv() is the function that will import the data to the data frame. "flavors_of_cacao.csv" is the file name that read.csv() function takes for its argument.
Next, you select the basic statistics that can help your team better understand the ratings system in your data. Assume the first part of your code is: trimmed_flavors_df %>% You want to use the summarize() and sd() functions to find the standard deviation of the rating for your data. Add the code chunk that lets you find the standard deviation for the variable Rating. 1 What is the standard deviation of the rating?
You add the code chunk summarize(sd(Rating)) to find the standard deviation for the variable Rating. The correct code is trimmed_flavors_df %>% summarize(sd(Rating)). In this code chunk: The summarize() function lets you display summary statistics. You can use the summarize() function in combination with other functions such as mean(), max(), and min() to calculate specific statistics. In this case, you use sd() to calculate the standard deviation statistic for the variable Rating. The standard deviation of the rating is 0.4780624.
After completing your analysis of the rating system, you determine that any rating greater than or equal to 3.5 points can be considered a high rating. You also know that Chocolate and Tea considers a bar to be super dark chocolate if the bar's cocoa percent is greater than or equal to 70%. You decide to create a new data frame to find out which chocolate bars meet these two conditions. Assume the first part of your code is: best_trimmed_flavors_df <- trimmed_flavors_df %>% You want to apply the filter() function to the variables Cocoa.Percent and Rating. Add the code chunk that lets you filter the data frame for chocolate bars that contain at least 70% cocoa and have a rating of at least 3.5 points. 1 What rating appears in row 1 of your tibble?
The code chunk filter(Cocoa.Percent >= 70, Rating >= 3.5) lets you filter the data frame for chocolate bars that contain at least 70% cocoa and have a rating of at least 3.5 points. The correct code is best_trimmed_flavors_df <- trimmed_flavors_df %>% filter(Cocoa.Percent >= 70, Rating >= 3.5). In this code chunk: The filter() function lets you filter your data frame based on specific criteria. Cocoa.Percent and Rating refer to the variables you want to filter. The >= operator signifies “greater than or equal to.” The new data frame will show all the values of Cocoa.Percent greater than or equal to 70, and all the values of Rating greater than or equal to 3.5. The rating 3.50 appears in row 1 of your tibble.
Ready to test your recall?
Your team already uses R. Why might they benefit from adopting R Markdown? Select all that apply.
How confident are you in this answer?