206,828 views
31 votes
31 votes
Q:

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.Location. 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 %>%

User Baumi
by
2.5k points

1 Answer

10 votes
10 votes

Answer:

To create a new data frame with only the Rating, Cocoa.Percent, and Company.Location variables using the select() function, you can use the following code:

Code:

# create a new data frame with only the Rating, Cocoa.Percent, and Company.Location variables

trimmed_flavors_df <- flavors_df %>%

select(Rating, Cocoa.Percent, Company.Location)

In this code, the trimmed_flavors_df variable will be assigned a new data frame that contains only the Rating, Cocoa.Percent, and Company.Location columns from the flavors_df data frame.

I hope this helps! Let me know if you have any questions.

User Paul Iluhin
by
2.8k points