Objectives

  • Learn where to get help with R.
  • Learn how to ask for help with R.

With a little help from my friends

rstudio default session

No matter how much experience you have with R, you will find yourself needing help. There is no shame in researching how to do something in R, and most people will find themselves looking up how to do the same things that they “should know how to do” over and over again. Here are some tips to make this process as helpful and efficient as possible.

“Never memorize something that you can look up” – A. Einstein

Finding help

There are a few websites that are useful for getting help with R. They can be summarized as follows:

Website Purpose
R Documentation Searchable documentation for R packages on CRAN and Bioconductor
Bioconductor Support Support forum for Bioconductor packages
stackoverflow General programming questions
Biostars Bioinformatics specific questions
UM CoderSpaces General and UM-specific questions

Getting help

If you are trying to get help on a forum, it best to follow some basic guidelines to make sure you get the help you need.

  • Check if a question has already been asked. Forum members can get touchy if duplicate questions are asked.
  • Clearly describe your problem in words. State what you’re trying to do, what you tried, and the result, including the full text of the error message.
  • Try to include a “minimally reproducible example.” This means providing data and code that anyone can run to reproduce the error, and diagnose the issue. Specifically, this means you can’t share large datasets, or idiosyncratic code.

The How to ask for R help blog post has some good examples of how to ask for help with R. Note that this advice largely generalizes to other programming languages.

Sharing your session info

Part of getting help, especially with R, is including your sessionInfo() with your question. This helps people know what packages and what versions you have installed. This will help reproduce the issue and possibly find a solution.

There are a couple ways to get the session information. The first is:

################################################################################
# Print out details about this R install, session, and loaded libraries
sessionInfo()
R version 4.5.0 (2025-04-11)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 22.04.5 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0 
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0  LAPACK version 3.10.0

locale:
 [1] LC_CTYPE=C.UTF-8       LC_NUMERIC=C           LC_TIME=C.UTF-8        LC_COLLATE=C.UTF-8     LC_MONETARY=C.UTF-8    LC_MESSAGES=C.UTF-8    LC_PAPER=C.UTF-8      
 [8] LC_NAME=C              LC_ADDRESS=C           LC_TELEPHONE=C         LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C   

time zone: America/Detroit
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] future_1.58.0       lubridate_1.9.4     forcats_1.0.0       stringr_1.5.1       dplyr_1.1.4         purrr_1.0.4         readr_2.1.5         tidyr_1.3.1         tibble_3.3.0       
[10] ggplot2_3.5.2       tidyverse_2.0.0     Seurat_5.3.0        SeuratObject_5.1.0  sp_2.2-0            knitr_1.50          kableExtra_1.4.0.15 klippy_0.0.0.9500   rmarkdown_2.29     

loaded via a namespace (and not attached):
  [1] RColorBrewer_1.1-3     rstudioapi_0.17.1      jsonlite_2.0.0         magrittr_2.0.3         spatstat.utils_3.1-4   farver_2.1.2           ragg_1.4.0            
  [8] vctrs_0.6.5            ROCR_1.0-11            spatstat.explore_3.4-3 htmltools_0.5.8.1      sass_0.4.10            sctransform_0.4.2      parallelly_1.45.0     
 [15] KernSmooth_2.23-26     bslib_0.9.0            htmlwidgets_1.6.4      ica_1.0-3              plyr_1.8.9             plotly_4.10.4          zoo_1.8-14            
 [22] cachem_1.1.0           igraph_2.1.4           mime_0.13              lifecycle_1.0.4        pkgconfig_2.0.3        Matrix_1.7-3           R6_2.6.1              
 [29] fastmap_1.2.0          fitdistrplus_1.2-2     shiny_1.10.0           digest_0.6.37          patchwork_1.3.0        tensor_1.5             RSpectra_0.16-2       
 [36] irlba_2.3.5.1          textshaping_1.0.1      labeling_0.4.3         progressr_0.15.1       timechange_0.3.0       spatstat.sparse_3.1-0  httr_1.4.7            
 [43] polyclip_1.10-7        abind_1.4-8            compiler_4.5.0         bit64_4.6.0-1          withr_3.0.2            fastDummies_1.7.5      MASS_7.3-65           
 [50] tools_4.5.0            lmtest_0.9-40          httpuv_1.6.16          future.apply_1.20.0    goftest_1.2-3          glue_1.8.0             nlme_3.1-168          
 [57] promises_1.3.3         grid_4.5.0             Rtsne_0.17             cluster_2.1.8.1        reshape2_1.4.4         generics_0.1.4         gtable_0.3.6          
 [64] spatstat.data_3.1-6    tzdb_0.5.0             data.table_1.17.4      hms_1.1.3              xml2_1.3.8             utf8_1.2.6             spatstat.geom_3.4-1   
 [71] RcppAnnoy_0.0.22       ggrepel_0.9.6          RANN_2.6.2             pillar_1.10.2          vroom_1.6.5            spam_2.11-1            RcppHNSW_0.6.0        
 [78] later_1.4.2            splines_4.5.0          lattice_0.22-7         survival_3.8-3         bit_4.6.0              deldir_2.0-4           tidyselect_1.2.1      
 [85] miniUI_0.1.2           pbapply_1.7-2          gridExtra_2.3          svglite_2.2.1          scattermore_1.2        xfun_0.52              matrixStats_1.5.0     
 [92] stringi_1.8.7          lazyeval_0.2.2         yaml_2.3.10            evaluate_1.0.3         codetools_0.2-20       cli_3.6.5              uwot_0.2.3            
 [99] xtable_1.8-4           reticulate_1.42.0      systemfonts_1.2.3      jquerylib_0.1.4        Rcpp_1.0.14            globals_0.18.0         spatstat.random_3.4-1 
[106] png_0.1-8              spatstat.univar_3.1-3  parallel_4.5.0         assertthat_0.2.1       dotCall64_1.2          listenv_0.9.1          viridisLite_0.4.2     
[113] scales_1.4.0           ggridges_0.5.6         crayon_1.5.3           rlang_1.1.6            cowplot_1.1.3         

The sessionInfo command will work in any R environment. For a slightly more elegant output, use devtools::session_info(). (Note, you’ll have to have the devtools package installed., which we have done for you.)

################################################################################
# A more concise, pleasant version of sessionInfo()
devtools::session_info()
─ Session info ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.5.0 (2025-04-11)
 os       Ubuntu 22.04.5 LTS
 system   x86_64, linux-gnu
 ui       RStudio
 language (EN)
 collate  C.UTF-8
 ctype    C.UTF-8
 tz       America/Detroit
 date     2025-06-19
 rstudio  2024.12.1+563 Kousa Dogwood (server)
 pandoc   3.2 @ /usr/lib/rstudio-server/bin/quarto/bin/tools/x86_64/ (via rmarkdown)
 quarto   1.5.57 @ /usr/lib/rstudio-server/bin/quarto/bin/quarto

─ Packages ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 package          * version    date (UTC) lib source
 abind              1.4-8      2024-09-12 [2] CRAN (R 4.5.0)
 assertthat         0.2.1      2019-03-21 [2] CRAN (R 4.5.0)
 bit                4.6.0      2025-03-06 [2] CRAN (R 4.5.0)
 bit64              4.6.0-1    2025-01-16 [2] CRAN (R 4.5.0)
 bslib              0.9.0      2025-01-30 [2] CRAN (R 4.5.0)
 cachem             1.1.0      2024-05-16 [2] CRAN (R 4.5.0)
 cli                3.6.5      2025-04-23 [2] CRAN (R 4.5.0)
 cluster            2.1.8.1    2025-03-12 [2] CRAN (R 4.5.0)
 codetools          0.2-20     2024-03-31 [2] CRAN (R 4.5.0)
 cowplot            1.1.3      2024-01-22 [2] CRAN (R 4.5.0)
 crayon             1.5.3      2024-06-20 [2] CRAN (R 4.5.0)
 data.table         1.17.4     2025-05-26 [2] CRAN (R 4.5.0)
 deldir             2.0-4      2024-02-28 [2] CRAN (R 4.5.0)
 devtools           2.4.5      2022-10-11 [2] CRAN (R 4.5.0)
 digest             0.6.37     2024-08-19 [2] CRAN (R 4.5.0)
 dotCall64          1.2        2024-10-04 [2] CRAN (R 4.5.0)
 dplyr            * 1.1.4      2023-11-17 [2] CRAN (R 4.5.0)
 ellipsis           0.3.2      2021-04-29 [2] CRAN (R 4.5.0)
 evaluate           1.0.3      2025-01-10 [2] CRAN (R 4.5.0)
 farver             2.1.2      2024-05-13 [2] CRAN (R 4.5.0)
 fastDummies        1.7.5      2025-01-20 [2] CRAN (R 4.5.0)
 fastmap            1.2.0      2024-05-15 [2] CRAN (R 4.5.0)
 fitdistrplus       1.2-2      2025-01-07 [2] CRAN (R 4.5.0)
 forcats          * 1.0.0      2023-01-29 [2] CRAN (R 4.5.0)
 fs                 1.6.6      2025-04-12 [2] CRAN (R 4.5.0)
 future           * 1.58.0     2025-06-05 [2] CRAN (R 4.5.0)
 future.apply       1.20.0     2025-06-06 [2] CRAN (R 4.5.0)
 generics           0.1.4      2025-05-09 [2] CRAN (R 4.5.0)
 ggplot2          * 3.5.2      2025-04-09 [2] CRAN (R 4.5.0)
 ggrepel            0.9.6      2024-09-07 [2] CRAN (R 4.5.0)
 ggridges           0.5.6      2024-01-23 [2] CRAN (R 4.5.0)
 globals            0.18.0     2025-05-08 [2] CRAN (R 4.5.0)
 glue               1.8.0      2024-09-30 [2] CRAN (R 4.5.0)
 goftest            1.2-3      2021-10-07 [2] CRAN (R 4.5.0)
 gridExtra          2.3        2017-09-09 [2] CRAN (R 4.5.0)
 gtable             0.3.6      2024-10-25 [2] CRAN (R 4.5.0)
 hms                1.1.3      2023-03-21 [2] CRAN (R 4.5.0)
 htmltools          0.5.8.1    2024-04-04 [2] CRAN (R 4.5.0)
 htmlwidgets        1.6.4      2023-12-06 [2] CRAN (R 4.5.0)
 httpuv             1.6.16     2025-04-16 [2] CRAN (R 4.5.0)
 httr               1.4.7      2023-08-15 [2] CRAN (R 4.5.0)
 ica                1.0-3      2022-07-08 [2] CRAN (R 4.5.0)
 igraph             2.1.4      2025-01-23 [2] CRAN (R 4.5.0)
 irlba              2.3.5.1    2022-10-03 [2] CRAN (R 4.5.0)
 jquerylib          0.1.4      2021-04-26 [2] CRAN (R 4.5.0)
 jsonlite           2.0.0      2025-03-27 [2] CRAN (R 4.5.0)
 kableExtra       * 1.4.0.15   2025-06-12 [3] Github (haozhu233/kableExtra@2f58f89)
 KernSmooth         2.23-26    2025-01-01 [2] CRAN (R 4.5.0)
 klippy           * 0.0.0.9500 2025-06-12 [3] Github (umich-brcf-bioinf/workshop-klippy@a1be090)
 knitr            * 1.50       2025-03-16 [2] CRAN (R 4.5.0)
 labeling           0.4.3      2023-08-29 [2] CRAN (R 4.5.0)
 later              1.4.2      2025-04-08 [2] CRAN (R 4.5.0)
 lattice            0.22-7     2025-04-02 [2] CRAN (R 4.5.0)
 lazyeval           0.2.2      2019-03-15 [2] CRAN (R 4.5.0)
 lifecycle          1.0.4      2023-11-07 [2] CRAN (R 4.5.0)
 listenv            0.9.1      2024-01-29 [2] CRAN (R 4.5.0)
 lmtest             0.9-40     2022-03-21 [2] CRAN (R 4.5.0)
 lubridate        * 1.9.4      2024-12-08 [2] CRAN (R 4.5.0)
 magrittr           2.0.3      2022-03-30 [2] CRAN (R 4.5.0)
 MASS               7.3-65     2025-02-28 [2] CRAN (R 4.5.0)
 Matrix             1.7-3      2025-03-11 [2] CRAN (R 4.5.0)
 matrixStats        1.5.0      2025-01-07 [2] CRAN (R 4.5.0)
 memoise            2.0.1      2021-11-26 [2] CRAN (R 4.5.0)
 mime               0.13       2025-03-17 [2] CRAN (R 4.5.0)
 miniUI             0.1.2      2025-04-17 [2] CRAN (R 4.5.0)
 nlme               3.1-168    2025-03-31 [2] CRAN (R 4.5.0)
 parallelly         1.45.0     2025-06-02 [2] CRAN (R 4.5.0)
 patchwork          1.3.0      2024-09-16 [2] CRAN (R 4.5.0)
 pbapply            1.7-2      2023-06-27 [2] CRAN (R 4.5.0)
 pillar             1.10.2     2025-04-05 [2] CRAN (R 4.5.0)
 pkgbuild           1.4.8      2025-05-26 [2] CRAN (R 4.5.0)
 pkgconfig          2.0.3      2019-09-22 [2] CRAN (R 4.5.0)
 pkgload            1.4.0      2024-06-28 [2] CRAN (R 4.5.0)
 plotly             4.10.4     2024-01-13 [2] CRAN (R 4.5.0)
 plyr               1.8.9      2023-10-02 [2] CRAN (R 4.5.0)
 png                0.1-8      2022-11-29 [2] CRAN (R 4.5.0)
 polyclip           1.10-7     2024-07-23 [2] CRAN (R 4.5.0)
 profvis            0.4.0      2024-09-20 [2] CRAN (R 4.5.0)
 progressr          0.15.1     2024-11-22 [2] CRAN (R 4.5.0)
 promises           1.3.3      2025-05-29 [2] CRAN (R 4.5.0)
 purrr            * 1.0.4      2025-02-05 [2] CRAN (R 4.5.0)
 R6                 2.6.1      2025-02-15 [2] CRAN (R 4.5.0)
 ragg               1.4.0      2025-04-10 [2] CRAN (R 4.5.0)
 RANN               2.6.2      2024-08-25 [2] CRAN (R 4.5.0)
 RColorBrewer       1.1-3      2022-04-03 [2] CRAN (R 4.5.0)
 Rcpp               1.0.14     2025-01-12 [2] CRAN (R 4.5.0)
 RcppAnnoy          0.0.22     2024-01-23 [2] CRAN (R 4.5.0)
 RcppHNSW           0.6.0      2024-02-04 [2] CRAN (R 4.5.0)
 readr            * 2.1.5      2024-01-10 [2] CRAN (R 4.5.0)
 remotes            2.5.0      2024-03-17 [2] CRAN (R 4.5.0)
 reshape2           1.4.4      2020-04-09 [2] CRAN (R 4.5.0)
 reticulate         1.42.0     2025-03-25 [2] CRAN (R 4.5.0)
 rlang              1.1.6      2025-04-11 [2] CRAN (R 4.5.0)
 rmarkdown        * 2.29       2024-11-04 [2] CRAN (R 4.5.0)
 ROCR               1.0-11     2020-05-02 [2] CRAN (R 4.5.0)
 RSpectra           0.16-2     2024-07-18 [2] CRAN (R 4.5.0)
 rstudioapi         0.17.1     2024-10-22 [2] CRAN (R 4.5.0)
 Rtsne              0.17       2023-12-07 [2] CRAN (R 4.5.0)
 sass               0.4.10     2025-04-11 [2] CRAN (R 4.5.0)
 scales             1.4.0      2025-04-24 [2] CRAN (R 4.5.0)
 scattermore        1.2        2023-06-12 [2] CRAN (R 4.5.0)
 sctransform        0.4.2      2025-04-30 [2] CRAN (R 4.5.0)
 sessioninfo        1.2.3      2025-02-05 [2] CRAN (R 4.5.0)
 Seurat           * 5.3.0      2025-04-23 [2] CRAN (R 4.5.0)
 SeuratObject     * 5.1.0      2025-04-22 [2] CRAN (R 4.5.0)
 shiny              1.10.0     2024-12-14 [2] CRAN (R 4.5.0)
 sp               * 2.2-0      2025-02-01 [2] CRAN (R 4.5.0)
 spam               2.11-1     2025-01-20 [2] CRAN (R 4.5.0)
 spatstat.data      3.1-6      2025-03-17 [2] CRAN (R 4.5.0)
 spatstat.explore   3.4-3      2025-05-21 [2] CRAN (R 4.5.0)
 spatstat.geom      3.4-1      2025-05-20 [2] CRAN (R 4.5.0)
 spatstat.random    3.4-1      2025-05-20 [2] CRAN (R 4.5.0)
 spatstat.sparse    3.1-0      2024-06-21 [2] CRAN (R 4.5.0)
 spatstat.univar    3.1-3      2025-05-08 [2] CRAN (R 4.5.0)
 spatstat.utils     3.1-4      2025-05-15 [2] CRAN (R 4.5.0)
 stringi            1.8.7      2025-03-27 [2] CRAN (R 4.5.0)
 stringr          * 1.5.1      2023-11-14 [2] CRAN (R 4.5.0)
 survival           3.8-3      2024-12-17 [2] CRAN (R 4.5.0)
 svglite            2.2.1      2025-05-12 [3] CRAN (R 4.5.0)
 systemfonts        1.2.3      2025-04-30 [2] CRAN (R 4.5.0)
 tensor             1.5        2012-05-05 [2] CRAN (R 4.5.0)
 textshaping        1.0.1      2025-05-01 [2] CRAN (R 4.5.0)
 tibble           * 3.3.0      2025-06-08 [2] CRAN (R 4.5.0)
 tidyr            * 1.3.1      2024-01-24 [2] CRAN (R 4.5.0)
 tidyselect         1.2.1      2024-03-11 [2] CRAN (R 4.5.0)
 tidyverse        * 2.0.0      2023-02-22 [2] CRAN (R 4.5.0)
 timechange         0.3.0      2024-01-18 [2] CRAN (R 4.5.0)
 tzdb               0.5.0      2025-03-15 [2] CRAN (R 4.5.0)
 urlchecker         1.0.1      2021-11-30 [2] CRAN (R 4.5.0)
 usethis            3.1.0      2024-11-26 [2] CRAN (R 4.5.0)
 utf8               1.2.6      2025-06-08 [2] CRAN (R 4.5.0)
 uwot               0.2.3      2025-02-24 [2] CRAN (R 4.5.0)
 vctrs              0.6.5      2023-12-01 [2] CRAN (R 4.5.0)
 viridisLite        0.4.2      2023-05-02 [2] CRAN (R 4.5.0)
 vroom              1.6.5      2023-12-05 [2] CRAN (R 4.5.0)
 withr              3.0.2      2024-10-28 [2] CRAN (R 4.5.0)
 xfun               0.52       2025-04-02 [2] CRAN (R 4.5.0)
 xml2               1.3.8      2025-03-14 [2] CRAN (R 4.5.0)
 xtable             1.8-4      2019-04-21 [2] CRAN (R 4.5.0)
 yaml               2.3.10     2024-07-26 [2] CRAN (R 4.5.0)
 zoo                1.8-14     2025-04-10 [2] CRAN (R 4.5.0)

 [1] /home/workshop/cgates/R/x86_64-pc-linux-gnu-library/4.5
 [2] /efs/workshop/R/library
 [3] /efs/workshop/R/workshop-dev-libs
 [4] /usr/local/lib/R/site-library
 [5] /usr/lib/R/site-library
 [6] /usr/lib/R/library
 * ── Packages attached to the search path.

────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Sharing your data

Many times, there may be some issues with your data and the way it is formatted. In that case, you may want to share that data with someone else. However, you may not need to share the whole dataset; looking at a subset of your 50,000 row, 10,000 column dataframe may be TMI (too much information)! You can take an object you have in memory such as dataframe (if you don’t know what this means yet, we will get to it!) and save it to a file. In our example we will use the dput() function on the iris dataframe which is an example dataset that is installed in R:

# iris is an example data.frame built into R
dput(head(iris)) # iris is an example data.frame that comes with R
structure(list(Sepal.Length = c(5.1, 4.9, 4.7, 4.6, 5, 5.4), 
    Sepal.Width = c(3.5, 3, 3.2, 3.1, 3.6, 3.9), Petal.Length = c(1.4, 
    1.4, 1.3, 1.5, 1.4, 1.7), Petal.Width = c(0.2, 0.2, 0.2, 
    0.2, 0.2, 0.4), Species = structure(c(1L, 1L, 1L, 1L, 1L, 
    1L), levels = c("setosa", "versicolor", "virginica"), class = "factor")), row.names = c(NA, 
6L), class = "data.frame")

This output very clearly states the structure of the iris data frame. Alternatively, you can also save objects in R memory to a file by specifying the name of the object, in this case the iris data frame, and passing a filename to the file= argument.

# By convention, we use the .rds file extension
saveRDS(iris, file="iris.rds")

# To load this type of file back
iris_rds = readRDS("iris.rds")

Final FAQs on R

Finally, here are a few pieces of introductory R knowledge that are too good to pass up. While we won’t return to them in this course, we put them here because they come up commonly:

Do I need to click Run every time I want to run a script?

  • No. In fact, the most common shortcut key allows you to run a command (or any lines of the script that are highlighted):
    • Windows execution shortcut: Ctrl+Enter
    • Mac execution shortcut: Cmd(⌘)+Enter
    To see a complete list of shortcuts, click on the Tools menu and select Keyboard Shortcuts Help

What’s with the brackets in R console output? - R returns an index with your result. When your result contains multiple values, the number tells you what ordinal number begins the line, for example:

1:101 # generates the sequence of numbers from 1 to 101
  [1]   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34
 [35]  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57  58  59  60  61  62  63  64  65  66  67  68
 [69]  69  70  71  72  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89  90  91  92  93  94  95  96  97  98  99 100 101

In the output above, [81] indicates that the first value on that line is the 81st item in your result

Can I run my R script without RStudio?

  • Yes, remember - RStudio is running R. You get to use lots of the enhancements RStudio provides, but R works independent of RStudio. See these tips for running your commands at the command line

Where else can I learn about RStudio? - Check out the Help menu, especially “Cheatsheets” section




Previous lesson Top of this lesson Next lesson