0
0
R Programmingprogramming~10 mins

filter() for row selection 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 select rows where the column 'age' is greater than 30.

R Programming
filtered_data <- filter(data, age [1] 30)
Drag options to blanks, or click blank then click option'
A>
B<
C==
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' will select rows with age less than 30.
Using '==' will select rows with age exactly 30.
2fill in blank
medium

Complete the code to select rows where the column 'score' is equal to 100.

R Programming
perfect_scores <- filter(data, score [1] 100)
Drag options to blanks, or click blank then click option'
A>
B!=
C==
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' instead of '==' causes an error in filter().
Using '!=' selects rows where score is not 100.
3fill in blank
hard

Fix the error in the code to select rows where 'height' is less than or equal to 170.

R Programming
short_people <- filter(data, height [1] 170)
Drag options to blanks, or click blank then click option'
A=>
B<=
C<
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=>' instead of '<=' causes a syntax error.
Using '<' excludes rows where height equals 170.
4fill in blank
hard

Fill both blanks to select rows where 'weight' is greater than 60 and 'age' is less than 50.

R Programming
selected <- filter(data, weight [1] 60, age [2] 50)
Drag options to blanks, or click blank then click option'
A>
B<
C==
D>=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' instead of '>' or '<' will select only exact matches.
Using '>=' or '<=' changes the condition to include equal values.
5fill in blank
hard

Fill all three blanks to select rows where 'score' is greater than 80, 'age' is less than 30, and 'height' equals 175.

R Programming
filtered <- filter(data, score [1] 80, age [2] 30, height [3] 175)
Drag options to blanks, or click blank then click option'
A<
B>
C==
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up operators like using '<' instead of '>' for score.
Using '=' instead of '==' for equality check.