0
0
R Programmingprogramming~10 mins

readRDS and saveRDS 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 save the object data to a file.

R Programming
saveRDS(data, [1])
Drag options to blanks, or click blank then click option'
A"datafile.txt"
B"datafile.rds"
Cdatafile.rds
Ddatafile
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to put the file name in quotes.
Using a wrong file extension like .txt.
2fill in blank
medium

Complete the code to read the saved RDS file into the variable loaded_data.

R Programming
loaded_data <- [1]("datafile.rds")
Drag options to blanks, or click blank then click option'
AreadRDS
Bread.csv
Cload
Dscan
Attempts:
3 left
💡 Hint
Common Mistakes
Using load which is for .RData files, not .rds.
Using read.csv which is for CSV files.
3fill in blank
hard

Fix the error in the code to correctly save the variable my_list to a file.

R Programming
saveRDS([1], "mylist.rds")
Drag options to blanks, or click blank then click option'
Amylist
B"my_list"
Cmy_list
Dlist
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong variable name without underscore.
Putting the variable name in quotes.
4fill in blank
hard

Fill both blanks to save df to a file and then read it back into df_copy.

R Programming
saveRDS([1], [2])
df_copy <- readRDS("dataframe.rds")
Drag options to blanks, or click blank then click option'
Adf
B"dataframe.rds"
Cdf_copy
D"df.rds"
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the object and file name.
Not using quotes around the file name.
5fill in blank
hard

Fill all three blanks to save results to a file, read it back into loaded_results, and check if they are identical.

R Programming
saveRDS([1], [2])
loaded_results <- [3]("results.rds")
identical(results, loaded_results)
Drag options to blanks, or click blank then click option'
Aresults
B"results.rds"
CreadRDS
Dload
Attempts:
3 left
💡 Hint
Common Mistakes
Using load instead of readRDS.
Not using quotes around the file name.