Troubleshooting and finding help Answer Key

Author

Will Gammerdinger

Published

July 1, 2025

Exercise 1

  1. Run the following code chunks and fix all of the errors. (Note: The code chunks are independent from one another.)
# Create a vector of work days
work_days <- c(Monday, Tuesday, Wednesday, Thursday, Friday)

Add quotation marks around the work days of the week

# Create a vector of work days
work_days <- c("Monday", "Tuesday", "Wednesday", "Thursday", "Friday")

# Create a function to round the output of the sum function
round_the_sum <- function(x){
        return(round(sum(x))
}

Add a closing parenthesis to close the return() function.

# Create a function to round the output of the sum function
round_the_sum <- function(x){
        return(round(sum(x)))
}

# Create a function to add together three numbers
add_numbers <- function(x,y,z){
        sum(x,y,z)
}

add_numbers(5,9)

Add a third value to the add_numbers() function.

# Create a function to add together three numbers
add_numbers <- function(x,y,z){
        sum(x,y,z)
}

add_numbers(5,9,3)
[1] 17
  1. You try to install a package and you get the following error message:
Warning

Error: package or namespace load failed for ‘Seurat’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]): there is no package called ‘multtest’

What would you do to remedy the error?

Install the package “multtest” from Bioconductor.

# The currently maintained version of multtest is on Bioconductor, so we need to load Bioconductor
library(BiocManager)
# Install the multtest package
BiocManager::install("multtest")
  1. You would like to ask for help on an online forum. To do this you want the users of the forum to reproduce your problem, so you want to provide them as much relevant information and data as possible.
  • You want to provide them with the list of packages that you currently have loaded, the version of R, your OS and package versions. Use the appropriate function(s) to obtain this information.
# Return the sessionInfo()
sessionInfo()
  • You want to also provide a small data frame that reproduces the error (if working with a large data frame, you’ll need to subset it down to something small). For this exercise use the data frame df, and save it as an RData object called df.RData.
# Save the df.RData object
save(df, file = "data/df.RData")
  • What code should the people looking at your help request should use to read in df.RData?
# Load the df.RData object
load(file="data/df.RData")