sales with exact entries: Bread = 15, Cookies = 8, Cake = 12, Pie = 5threshold and set it to 10%>% to filter sales for items with sales greater than threshold and then convert the item names to uppercasesales with exact entries: Bread = 15, Cookies = 8, Cake = 12, Pie = 5threshold and set it to 10%>% to filter sales for items with sales greater than threshold and then convert the item names to uppercasesales with these exact entries: Bread = 15, Cookies = 8, Cake = 12, Pie = 5Use c() to create a named vector with names and values separated by =.
threshold and set it to 10Just assign the number 10 to the variable threshold.
%>% to filter sales for items with sales greater than threshold and then convert the item names to uppercase. Store the result in a variable called top_items. Use magrittr::extract() or base R to filter and names() with toupper() to convert names.Use %>% to chain filtering and renaming. Filtering keeps sales above threshold. Then change names to uppercase with toupper().
print(top_items) to display the filtered and renamed sales vector.Use print(top_items) to show the final filtered and renamed vector.
What does the pipe operator %>% do in R?
%>% takes the result from the left side and passes it as the first argument to the function on the right side.Which of the following is the correct syntax to use pipe chaining in R?
library(dplyr)
data <- data.frame(x = 1:3, y = 4:6)
data %>% ? %>% head()filter(x > 1).What is the output of this R code?
library(dplyr) data <- tibble(x = 1:5, y = 6:10) data %>% filter(x > 2) %>% mutate(z = x + y) %>% pull(z)
Find the error in this pipe chain and select the fix:
library(dplyr) data <- tibble(a = 1:4, b = 5:8) data %>% filter(a > 2) %>% mutate(c = a + b) %>% select(c, d)
c and d, but d does not exist in the data.select(c, d) to select(c) removes the error by selecting only the existing column c.select(c, d) to select(c) -> Option DUsing pipe chaining, how can you transform this data frame df to get the sum of squares of even numbers in column num?
df <- data.frame(num = 1:6)
Choose the correct pipe chain.
filter(num %% 2 == 0) to keep only even numbers.mutate(sq = num^2) to add squared values.summarise(total = sum(sq)) to get the sum of squares.Pass the test and this pattern moves unknown