Skip to the content.

Approximate time: 30 min

Learning Objectives

Asking for help

The key to getting help from someone is for them to grasp your problem rapidly. You should make it as easy as possible to pinpoint where the issue might be.

  1. Try to use the correct words to describe your problem. For instance, a package is not the same thing as a library. Most people will understand what you meant, but others have really strong feelings about the difference in meaning. The key point is that it can make things confusing for people trying to help you. Be as precise as possible when describing your problem.

  2. Always include the output of sessionInfo() as it provides critical information about your platform, the versions of R and the packages that you are using, and other information that can be very helpful to understand your problem.

     sessionInfo()  #This time it is not interchangeable with search()
    
  3. If possible, reproduce the problem using a very small data.frame instead of your 50,000 rows and 10,000 columns one, provide the small one with the description of your problem. When appropriate, try to generalize what you are doing so even people who are not in your field can understand the question.

    • To share an object with someone else, you can provide either the raw file (i.e., your CSV file) with your script up to the point of the error (and after removing everything that is not relevant to your issue). Alternatively, in particular if your questions is not related to a data.frame, you can save any other R data structure that you have in your environment to a file:

        # DO NOT RUN THIS!
      
        save(iris, file="/tmp/iris.RData")
      

      The content of this .RData file is not human readable and cannot be posted directly on stackoverflow. It can, however, be emailed to someone who can read it with this command:

        # DO NOT RUN THIS!
      
        load(file="~/Downloads/iris.RData")
      

Where to ask for help?

More resources


Exercises

  1. Run the following code chunks and fix all of the errors. (Note: The code chunks are independent from one another.)

     # Create 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))
     }
    
     # Create a function to add together three numbers
     add_numbers <- function(x,y,z){
             sum(x,y,z)
     }
    	
     add_numbers(5,9)
    	
    
  2. You try to install a package and you get the following error message:

     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?

  3. 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.
    • 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.
    • What code should the people looking at your help request should use to read in df.RData?

This lesson has been developed by members of the teaching team at the Harvard Chan Bioinformatics Core (HBC). These are open access materials distributed under the terms of the Creative Commons Attribution license (CC BY 4.0), which permits unrestricted use, distribution, and reproduction in any medium, provided the original author and source are credited.