0
0
R Programmingprogramming~10 mins

Filtering rows 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 filter rows where the column 'age' is greater than 30.

R Programming
filtered_data <- subset(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 where age is exactly 30.
2fill in blank
medium

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

R Programming
filtered_data <- subset(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 assignment, not comparison.
Using '!=' selects rows not equal to 100.
3fill in blank
hard

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

R Programming
filtered_data <- subset(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 '<' excludes rows where height equals 170.
Using '>=' selects rows with height greater than or equal to 170.
4fill in blank
hard

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

R Programming
filtered_data <- subset(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 '>=' or '<=' changes the condition to include equal values.
Mixing up the operators reverses the intended filter.
5fill in blank
hard

Fill all three blanks to filter rows where 'score' is greater than 80, 'age' is less than 30, and 'height' is at least 160.

R Programming
filtered_data <- subset(data, score [1] 80 & age [2] 30 & height [3] 160)
Drag options to blanks, or click blank then click option'
A>
B<
C>=
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<=' instead of '>=' for height changes the condition.
Mixing up operators leads to wrong filtering.