0
0
R Programmingprogramming~10 mins

Why advanced features enable complex work in R Programming - Test Your Understanding

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

Complete the code to create a vector of numbers from 1 to 5.

R Programming
numbers <- [1](1, 5)
Drag options to blanks, or click blank then click option'
Arep
Bseq
Cc
Dlist
Attempts:
3 left
💡 Hint
Common Mistakes
Using c creates a vector but does not generate a sequence automatically.
Using rep repeats values instead of creating a sequence.
2fill in blank
medium

Complete the code to calculate the mean of the vector 'values'.

R Programming
average <- [1](values)
Drag options to blanks, or click blank then click option'
Amean
Bsum
Cmedian
Dlength
Attempts:
3 left
💡 Hint
Common Mistakes
Using sum returns the total, not the average.
Using length returns the count of elements, not the average.
3fill in blank
hard

Fix the error in the code to subset the vector 'data' for values greater than 10.

R Programming
subset <- data[data [1] 10]
Drag options to blanks, or click blank then click option'
A>
B<=
C==
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using == selects only values exactly equal to 10.
Using <= or < selects smaller or equal values.
4fill in blank
hard

Fill both blanks to create a named list with elements 'a' and 'b'.

R Programming
my_list <- list([1] = 1, [2] = 2)
Drag options to blanks, or click blank then click option'
Aa
B1
Cb
D2
Attempts:
3 left
💡 Hint
Common Mistakes
Using numbers as names instead of letters.
Confusing values with names.
5fill in blank
hard

Fill all three blanks to create a data frame with columns 'name' and 'age' and filter rows where age is greater than 20.

R Programming
df <- data.frame([1] = c("Alice", "Bob"), [2] = c(25, 19))
adults <- df[df$[3] > 20, ]
Drag options to blanks, or click blank then click option'
Aname
Bage
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up column names and values.
Using the wrong column name in the filter condition.