Chapter 7 Getting help

7.0.1 Function help

The help() function and ? help operator in R provide access to the documentation pages for R functions, data sets, and other objects, both for packages in the standard R distribution and for contributed packages.

To get general help with help.start function just type the below command

help.start()

To access documentation for the mean function, for example, enter the command.

help(mean)

OR

help("mean")

OR

?lm

OR

?"lm"

All above commands serves same purpose. You can follow any expressions of your choice!

?? Search R help files for a word or phrase

Two question marks will search R documentation for a phrase or term. So for example, let’s say you want to search documentation for tools on regression or network analysis. Keep in mind if your phrase is more than one word long, you must put it in quotation marks.

To get help for a function in a package that’s not currently loaded, specify in addition the name of the package: For example, to obtain documentation for the bind_rows()  function in the dplyr package, help(bind_rows, package=“dplyr”).

RSiteSearch(): Search search.r-project.org

This function, included in base R, will search r-project.org’s internal search engine. Use it for further information on a concept or library. All terms must be placed in quotation marks.

This will open the search results in the default browser on your computer.

help(bind_rows, package="dplyr")

Vignettes and Code Demonstrations

Many packages include vignettes, which are discursive documents meant to illustrate and explain facilities in the package. You can discover vignettes by accessing the help page for a package, or via the browseVignettes() function. Below command shows show available vingettes.

vignette()

Below command shows the vignettes of ggplot2 package.

browseVignettes(package="ggplot2")

Demos

Packages may also include extended code demonstrations (“demos”). The command demo() lists all demos for all packages in your library, while demo(package=“package-name”) (e.g., demo(package=“stats”)) lists demos in a particular package. To run a demo, call the demo() function with the quoted name of the demo (e.g., demo(“nlm”)), specifying the name of the package if the name of the demo isn’t unique (e.g., demo(“nlm,” package=“stats”), where, in this case, the package name need not be given explicitly).

7.0.2 Getting help online from R community

R community is among the best in their class when it comes to provide help. If you ever searched for answers related to R, you might have see the following two sources frequently. Stackoverflow is my personal favourite to get help around complex R programming problems.

How to get prompt response on stackoverflow

I find stackoverflow the best source to get help from ten of thousands of expert R programmers. Key to get quick answers is to ask your question PROPERLY. A bad quest would get a down rating by the moderators and might never be answered. A good question must include following three steps.

https://stackoverflow.com/questions/ask

Here is an example stackoverflow question:

## app.R ##
library(shiny)
library(shinydashboard)

ui <- dashboardPage(

  dashboardHeader(),
  ## Sidebar content
  dashboardSidebar(
    sidebarMenu(
      menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard"))
    )
  ),

  ## Body content
  dashboardBody(
    tabItems(
      # First tab content
      tabItem(tabName = "dashboard",
              actionButton("showTable", "Show Table", icon = icon("table"))
              ##fluidRow( DT::dataTableOutput('tbl') )
              ## SOME CODE TO SHOW DATA TABLE IN MODAL
      )
    )
  )
)

server <- function(input, output) { 
  output$tbl = DT::renderDataTable(
    iris, options = list(lengthChange = FALSE) 
  )
}

shinyApp(ui, server)

Tags: r shiny shinydashboard dt

7.0.3 Cheatsheets

RStudio cheatsheets make it easy to use commonly used R packages. More and more cheatsheets are added time to time.

https://www.rstudio.com/resources/cheatsheets/