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.
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.
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).
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”).
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.
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.
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).
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”).
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
Another benefit of using R for the project is that it can easily reproduce and share an analysis.
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.
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.).
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.
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.
Another benefit of using R for the project is R’s ability to create high-quality data visualizations.
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.
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.
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.
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.
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.
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.
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).
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”).
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.
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.
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.
Your team already uses R. Why might they benefit from adopting R Markdown? Select all that apply.
How confident are you in this answer?