0
0
R Programmingprogramming~10 mins

paste and paste0 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 join the words with a space using paste.

R Programming
result <- paste("Hello", "World", sep=[1])
print(result)
Drag options to blanks, or click blank then click option'
A"-"
B","
C" "
D"_"
Attempts:
3 left
💡 Hint
Common Mistakes
Using a comma or dash instead of a space as separator.
Forgetting to put the separator inside quotes.
2fill in blank
medium

Complete the code to join the words without any separator using paste0.

R Programming
result <- paste0("Hello", [1], "World")
print(result)
Drag options to blanks, or click blank then click option'
A""
B" "
C", "
D"-"
Attempts:
3 left
💡 Hint
Common Mistakes
Using a space or comma as separator with paste0.
Confusing paste and paste0 functions.
3fill in blank
hard

Fix the error in the code to correctly join numbers and strings using paste.

R Programming
result <- paste("Age:", [1])
print(result)
Drag options to blanks, or click blank then click option'
A25
B"25"
Cc(25)
Das.character(25)
Attempts:
3 left
💡 Hint
Common Mistakes
Passing numbers directly without conversion.
Using quotes around numbers incorrectly.
4fill in blank
hard

Fill both blanks to create a named vector where names are uppercase and values are joined strings.

R Programming
words <- c("apple", "banana", "cherry")
names(words) <- toupper(words)
result <- sapply(words, function(w) paste(w, [1], sep=[2])
print(result)
Drag options to blanks, or click blank then click option'
A"fruit"
B", "
C"-"
D" "
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong separator characters.
Not quoting the string to join.
5fill in blank
hard

Fill all three blanks to create a vector of joined strings with no separator and uppercase names.

R Programming
words <- c("dog", "cat", "bird")
names(words) <- [1](words)
result <- sapply(words, function(w) paste0(w, [2], [3]))
print(result)
Drag options to blanks, or click blank then click option'
Atoupper
B"_"
C"pet"
Dtolower
Attempts:
3 left
💡 Hint
Common Mistakes
Using tolower instead of toupper.
Using paste instead of paste0.
Forgetting to quote strings.