PRACTICE QUIZ
A data analyst is considering using tibbles instead of basic data frames. What are some of the limitations of tibbles? Select all that apply.
A data analyst is working with a data frame called salary_data. They want to create a new column named hourly_salary that includes data from the wages column divided by 40. What code chunk lets the analyst create the hourly_salarycolumn?
A data analyst is working with a data frame named weather. It has separate columns for temperatures (temp) and measurement units (unit). The analyst wants to combine the two columns into a single column called display_temp, with the temperature and unit separated by the string “ Degrees “. What code chunk lets the analyst create the display_temp column?
In R, which statistical measure can help you understand the spread of values in a dataset and describe how far each value is from the mean?
A data scientist is trying to print a data frame but when you print the data frame to the console output produces too many rows and columns to be readable. What could they use instead of a data frame to make printing more readable?
A data analyst is working with a large data frame. It contains so many columns that they don’t all fit on the screen at once. The analyst wants a quick list of all of the column names to get a better idea of what is in their data. What function should they use?
A data analyst is working with the penguins dataset. What code chunk does the analyst write to make sure all the column names are unique and consistent and contain only letters, numbers, and underscores?
A data analyst is working with the penguins data. The variable species includes three penguin species: Adelie, Chinstrap, and Gentoo. The analyst wants to create a data frame that only includes the Adelie species. The analyst receives an error message when they run the following code: penguins %>% filter(species <- “Adelie”) How can the analyst change the second line of code to correct the error?
A data analyst is working with a data frame named retail. It has separate columns for dollars (price_dollars) and cents (price_cents). The analyst wants to combine the two columns into a single column named price, with the dollars and cents separated by a decimal point. For example, if the value in the price_dollars column is 10, and the value in the price_centscolumn is 50, the value in the pricecolumn will be 10.50. What code chunk lets the analyst create the pricecolumn?
A data analyst is using statistical measures to get a better understanding of their data. What function can they use to determine how strongly related are two of the variables?
A data analyst creates two different predictive models for the same dataset. They use the bias() function on both models. The first model has a bias of 20. The second model has a bias of 0.1. Which model is less biased?
You are cleaning a data frame with improperly formatted column names. In order to clean the data frame you want to use the clean_names() function. Which column names will be changed using the clean_names() with default parameters? Select all that apply.
A data analyst is working with the penguins dataset. The variable island represents the island on which the sample was collected. The analyst wants to create a data frame that excludes records from the island named “Torgersen”. What code chunk will allow them to create this data frame?
A data analyst is working with a data frame called zoo_records. They want to create a new column named is_large_animal that signifies if an animal has a weight of more than 199 kilograms. What code chunk lets the analyst create the is_large_animal column?
You are compiling an analysis of the average monthly costs for your company. What summary statistic function should you use to calculate the average?
A data analyst creates a data frame with data that has more than 50,000 observations in it. When they print their data frame, it slows down their console. To avoid this, they decide to switch to a tibble. Why would a tibble be more useful in this situation?
You have a data frame named employees with a column named Last_NAME. What will the name of the employees column be in the results of the function rename_with(employees, tolower)?
A data analyst is working with the penguins data. They write the following code: penguins %>% The variable species includes three penguin species: Adelie, Chinstrap, and Gentoo. What code chunk does the analyst add to create a data frame that only includes the Gentoo species?
A data analyst is working with a data frame named users. It has separate columns for first name (first_name) and last name (last_name). The analyst wants to combine the two columns into a single column called full_name, with the first name and last name separated by a space. What code chunk lets the analyst create the full_namecolumn?
A data analyst is working with a data frame named salary_data. They want to create a new column named wagesthat includes data from the rate column multiplied by 40. What code chunk lets the analyst create the wages column?
A data analyst writes the following code chunk to return a statistical summary of their dataset: quartet %>% group_by(set) %>% summarize(mean(x), sd(x), mean(y), sd(y), cor(x, y)) Which function will return the average value of the y column?
A data analyst is working with a dataset in R that has more than 50,000 observations. Why might they choose to use a tibble instead of the standard data frame? Select all that apply.
A data analyst is examining a new dataset for the first time. They load the dataset into a data frame to learn more about it. What function(s) will allow them to review the names of all of the columns in the data frame? Select all that apply.
A data analyst is working with a data frame named customers. It has separate columns for area code (area_code) and phone number (phone_num). The analyst wants to combine the two columns into a single column called phone_number, with the area code and phone number separated by a hyphen. What code chunk lets the analyst create the phone_numbercolumn?
A data analyst wants a high level summary of the structure of their data frame, including the column names, the number of rows and variables, and type of data within a given column. What function should they use?
You are working with the ToothGrowth dataset. You want to use the select() function to view all columns except the supp column. Write the code chunk that will give you this view. How many columns does the resulting data frame contain?
You are working with the penguins dataset. You want to use the summarize() and min() functions to find the minimum value for the variable bill_depth_mm. At this point, the following code has already been written into the script: penguins %>% drop_na() %>% group_by(species) %>% Add the code chunk that lets you find the minimum value for the variable bill_depth_mm. (Note: do not type the above code into the code block editor, as it has already been inputted. Simply add a single line of code based on the prompt.) What is the minimum bill depth in mm for the Chinstrap species?
The code chunk summarize(min(bill_depth_mm)) lets you find the minimum value for the variable bill_depth_mm. The correct code is penguins %>% drop_na() %>% group_by(species) %>% summarize(min(bill_depth_mm)). The summarize() function displays 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 min() to calculate the minimum value for bill depth. The minimum bill depth for the Chinstrap species is 16.4mm.
A data analyst wants to find out how much the predicted outcome and the actual outcome of their data model differ. What function can they use to quickly measure this?
You are working with the ToothGrowth dataset. You want to use the skim_without_charts() function to get a comprehensive view of the dataset. Write the code chunk that will give you this view. What is the average value of the len column?
A data analyst is working with the penguins dataset and wants to sort the penguins by body_mass_g from least to greatest. When they run the following code the penguin body mass data is not displayed in the correct order. penguins %>% arrange(body_mass_g) head(penguins) What can the data analyst do to fix their code? b)the capitalization of arrange() to Arrange()
You are working with the penguins dataset and want to understand the year of data collection for all combinations of species, island, and sex. At this point, the following code has already been written into your script: penguins %>% drop_na() %>% group_by(species, island, sex) %>% summarize(min = min(year), max = max(year)) When you run the code in the code box, how many separate observational rows are returned by this code chunk?
A data analyst is working with a data frame called athletes. The data frame contains a column names record that represents an athlete's wins and losses separated by a hyphen (-). They want to turn this single column into individual columns for wins and losses. Which code chunk lets the analyst split the record column?
A data analyst is working with a data frame named stores. It has separate columns for city (city) and state (state). The analyst wants to combine the two columns into a single column named location, with the city and state separated by a comma. What code chunk lets the analyst create the location column?
A data analyst is working with the penguins dataset in R. What code chunk will allow them to sort the penguins data by the variable bill_length_mm?
A data analyst is working with a data frame called salary_data. They want to create a new column named total_wages that adds together data in the standard_wages and overtime_wagescolumns.
What scenarios would prevent you from being able to use a tibble?
You are working with the ToothGrowth dataset. You want to use the skim_without_charts() function to get a comprehensive view of the dataset. Write the code chunk that will give you this view. How many rows does the ToothGrowth dataset contain?
The code chunk skim_without_charts(ToothGrowth) gives you a comprehensive view of the dataset. Inside the parentheses of the skim_without_charts() function is the name of the dataset you want to view. The code returns a summary with the name of the dataset and the number of rows and columns. It also shows the column types and data types contained in the dataset. The ToothGrowth dataset contains 60 rows.
In R, which statistical measure demonstrates how strong the relationship is between two variables?
A data analyst is studying weather data. They write the following code chunk: bias(actual_temp, predicted_temp) What will this code chunk calculate?
A data analyst wants to learn more about a specific data frame. Which function will allow them to review the data types of each column in the data frame?
You are working with the ToothGrowth dataset. You want to use the glimpse() function to get a quick summary of the dataset. Write the code chunk that will give you this summary. 1 2 How many different data types are used for the column data types?
You are working with the penguins dataset. You want to use the summarize() and mean() functions to find the mean value for the variable body_mass_g. At this point, the following code has already been written into your script: penguins %>% drop_na() %>% group_by(species) %>% Add the code chunk that lets you find the mean value for the variable body_mass_g. (Note: do not type the above code into the code block editor, as it has already been inputted. Simply add a single line of code based on the prompt.) What is the mean body mass in g for the Adelie species?
The code chunk summarize(mean(body_mass_g)) lets you find the mean value for the variable body_mass_g. The correct code is penguins %>% drop_na() %>% group_by(species) %>% summarize(mean(body_mass_g)). The summarize() function displays 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 mean() to calculate the mean value for body mass. The mean body mass for the Adelie species is 3706.164g.
A data analyst is working with a data frame called sales. In the data frame, a column named location represents data in the format “city, state”. The analyst wants to split the city into an individual city column and state into a new countrycolumn. What code chunk lets the analyst split the location column?
What is an advantage of using data frames instead of tibbles?
A data analyst is checking a script for one of their peers. They want to learn more about a specific data frame. What function(s) will allow them to see a subset of data values in the data frame? Select all that apply.
Ready to test your recall?
A data analyst is considering using tibbles instead of basic data frames. What are some of the limitations of tibbles? Select all that apply.
How confident are you in this answer?