0
0
R Programmingprogramming~10 mins

Pipe operator (%>% and |>) in R Programming - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to use the pipe operator to pass 'data' to the 'summary' function.

R Programming
result <- data [1] summary()
Drag options to blanks, or click blank then click option'
A->
B|>
C<-
D%>%
Attempts:
3 left
💡 Hint
Common Mistakes
Using assignment operators like <- instead of a pipe.
Confusing the pipe with other operators.
2fill in blank
medium

Complete the code to pipe 'numbers' into the 'mean' function using the native R pipe operator.

R Programming
average <- numbers [1] mean()
Drag options to blanks, or click blank then click option'
A->
B%>%
C|>
D<-
Attempts:
3 left
💡 Hint
Common Mistakes
Using %>% when the question asks for the native pipe.
Using assignment operators instead of pipes.
3fill in blank
hard

Fix the error in the code by choosing the correct pipe operator to chain 'data' to 'head' function.

R Programming
data [1] head(3)
Drag options to blanks, or click blank then click option'
A%>%
B->
C<-
D|>
Attempts:
3 left
💡 Hint
Common Mistakes
Using assignment operators instead of pipes.
Confusing the native pipe with magrittr pipe.
4fill in blank
hard

Fill both blanks to create a pipeline that filters 'df' for values > 10 and then selects the 'score' column.

R Programming
result <- df [1] filter(value [2] 10)
Drag options to blanks, or click blank then click option'
A%>%
B>
C|>
D<-
Attempts:
3 left
💡 Hint
Common Mistakes
Using assignment operators instead of pipes.
Using wrong comparison operators like < or =.
5fill in blank
hard

Fill all three blanks to create a pipeline that takes 'data', filters rows where 'age' is less than 30, then selects 'name' column.

R Programming
result <- data [1] filter(age [2] 30) [3] select(name)
Drag options to blanks, or click blank then click option'
A%>%
B<
C|>
D->
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong pipe operators in wrong places.
Mixing assignment and pipe operators incorrectly.