0
0
R Programmingprogramming~10 mins

Data frame creation 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 create a data frame with columns 'Name' and 'Age'.

R Programming
df <- data.frame(Name = c("Alice", "Bob"), Age = c(25, [1]))
Drag options to blanks, or click blank then click option'
A30
B"30"
CAge
Dc(30)
Attempts:
3 left
💡 Hint
Common Mistakes
Putting quotes around numbers, which makes them strings.
Using a variable name instead of a value.
2fill in blank
medium

Complete the code to create a data frame with three columns: 'ID', 'Score', and 'Passed'.

R Programming
df <- data.frame(ID = 1:3, Score = c(88, 92, 79), Passed = c(TRUE, [1], FALSE))
Drag options to blanks, or click blank then click option'
A1
B"TRUE"
CTRUE
DFALSE
Attempts:
3 left
💡 Hint
Common Mistakes
Using strings "TRUE" or "FALSE" instead of logical values.
Using numeric 1 or 0 instead of TRUE or FALSE.
3fill in blank
hard

Fix the error in the code to create a data frame with columns 'Product' and 'Price'.

R Programming
df <- data.frame(Product = c("Pen", "Notebook"), Price = c(1.5, [1]))
Drag options to blanks, or click blank then click option'
A2.0
B"2.0"
Cprice
Dc(2.0)
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around numbers.
Using variable names instead of values.
4fill in blank
hard

Fill both blanks to create a data frame with columns 'City' and 'Population' where population is numeric.

R Programming
df <- data.frame(City = c("NY", "LA", "SF"), Population = c([1], [2], 3000000))
Drag options to blanks, or click blank then click option'
A8000000
B"4000000"
C3000000
Dc(3000000)
Attempts:
3 left
💡 Hint
Common Mistakes
Using strings for numbers.
Using c() inside c(), which causes errors.
5fill in blank
hard

Fill all three blanks to create a data frame with columns 'Name', 'Age', and 'Member' where 'Member' is logical.

R Programming
df <- data.frame(Name = c("Anna", [1], "John"), Age = c(28, 34, [2]), Member = c(TRUE, [3], FALSE))
Drag options to blanks, or click blank then click option'
A"Mike"
B30
CFALSE
D"30"
Attempts:
3 left
💡 Hint
Common Mistakes
Using numbers as strings for Age.
Using strings for logical values in Member.
Not quoting names.