9 Ways to Get Help in R Language

In this article, we will discuss 9 ways to get help in R Language. R Language has a very useful and advanced help system that helps the R user to understand the R language and lets him know how programming should be done in the R language.

Get Help in R Language

To get help in R language you need to click the Help button on the toolbar of RGui (R Graphical User Interface) windows. If you have internet access on your PC you can type CRAN in Google and search for the help you need at CRAN.

Use of “?” for Help

On the other hand, if you know the name of the function, you need to type the question mark (?) followed by the name of the required function on the R command line prompt. For example to get help about “lm” function type ?lm and then press the ENTER key from the keyboard.
help(lm) or ?lm have the same search results in the R language.

help.start()

Getting General help in R write the following command at the R command prompt

help.start()

## Output
help.start()
starting httpd help server ... done
If nothing happens, you should open
‘http://127.0.0.1:13825/doc/html/index.html’ yourself
9 ways to get help in R Language

Sometimes it is difficult to remember the precise name of the function, but you know the subject on which you need help for example data input. Use the help.search function (without question mark) with your query in double quotes like this:

help.search("data input")

Press the ENTER key, you will see the names of the R functions associated with the query.  After that, you can easily use ?lm to get help in R.

Use of find(” “)

Getting help in R, find, and apropos are also useful functions. The find function tells you what package something is in: for example

find("cor") gives output that the cor in the stats package.

Use of apropos()

The apropos function returns a character vector giving the names of all objects in the search list that match your inquiry (potentially partial) i.e., this command lists all functions containing your string. For example

apropos("lm")

will give the list of all functions containing the string lm

Use of example()

example(lm) will provide an example of your required function that is in this case, an example of the function lm()

Online Help

There is a huge amount of information about R on the web. On CRAN you will find a variety of help/ manuals. There are also answers to FAQs (Frequently Asked Questions) and R News (contains interesting articles, book reviews, and news of forthcoming releases. The search facility of the site allows you to investigate the contents of the R documents, functions, and searchable mail archives.

You can search your required function or string in help manuals and archived mailing lists by using

RSiteSearch("read.csv")

Get Vignettes

vignette is an R jargon for documentation and is written in the spirit of sharing knowledge, and
assisting new users in learning the purpose and use of a package. To get some help in R try ?vignette. Vignettes are optional supplemental documentation, that’s why not all packages come with vignettes.

vignette()          # will show available vignettes
vignette("foo")     # will show specific vignette

Now you have learned about getting help in R, now you can continue with the other R tutorials. It is possible that you do not understand something discussed in the coming R tutorials. If this happens then you should use the built-in help system before going to the internet. In most cases, the help system of R Language will give you enough information about the required function that you have searched for.

Some Sources of R Help/ Manual/ Documentations

https://cran.r-project.org/manuals.html

https://cran.r-project.org/other-docs.html

https://www.r-project.org/help.html

https://cran.r-project.org/bin/windows/base/rw-FAQ.html

R Objects, Workspace, and .RData file

The post is about an introduction to workspace, R objects, and .Rdata file in R language.

R Language as Functional Language

The R program’s structure is similar to the programs written in other computer languages such as C or its successors C++ and Java. However, important differences between these languages and R are (i) R has no header files, (ii) most of the declarations are implicit, (iii) there are no pointers in R, and (iv) text and strings as vectors can be defined and manipulated directly.

R is a functional language. Most of the computation in R is handled using functions. The R language environment is designed to facilitate the development of new scientific computation tools.

R Objects

Everything (such as functions and data structure) in R is an object. To see the names of all R objects in the workspace, on the R command prompt just type,

ls()

objects() is an alternative to ls() function. Similarly, typing the name of any object on the R prompt displays (prints) the content of that object. As an example type q, mean, and lm, etc. on the R prompt.

R Workspace

It is possible to save individual objects or collections of objects into a named image file. The named image file has an extension of .RData. Some possibilities to save an object from R workspace are:

To save the content of R workspace into a file .RData, type

save.image()

To save objects in the file archive.RData, type

save.image(file = "archive.RData")

To save some required objects in data.RData, type

save(x, y, file = "data.RData")

These image files can be attached to make objects available in the next R session. For example.

attached ("arvhive.RData")
R workspace, R Objects

Note that when quitting, R offers the option of saving the workspace image. By default, the workspace is saved in an image file (.RData) in the working directory. The image file can be used in the next R session. Saving the workspace image will save everything from the current workspace. Therefore, use the rm() function to remove objects that are not further required in the next R session.

For further details about saving and loading R workspace visit: Save and Load R Workspace

Learn Statistics and Data Analysis

Objects in R Language: Secrets

The post is about objects in R Language. In R everything is an object. The commands run in a session can be saved or loaded in a file as history.

Loading Saved Work

Question 1: How can I retrieve (load) the saved work using the history function in R?
Answer: The loadhistory() function will load an “.Rhistory” file.

loadhistory("d:/file_name.Rhistory")

This function will load the file named “file_name.Rhistory” from D: drive.

The other way may be to access the “.Rhistory” file through the file menu. For this click File and then Load History. From the dialog box, browse the folder where you saved the “.Rhistory” file and click open to start working.

Script File in R

Question 2: How do I use a script of commands and functions saved in a text file?
Answer: The script of commands and functions saved in a text file (also called a script file) can be used to write the following command.

source("d:/file_name.txt")

The “file_name.txt” will load from D: drive.

Question 3: How do I get R to echo back the R commands and functions in a script file that I am sourcing into R? That is, the functions that I have written, I want to see these functions are being executed.
Answer: use echo=TRUE argument by using source() function

source("d:/file_name.txt", echo = T)

Question 4: How do I close the help file when working on a Macintosh operating system?
Answer: Typing just q will close the help file and bring you back to the R console.

Objects in R Language: Currently Available Objects

Question 5: How can I see a list of currently available objects in R?
Answer: Use the objects() or ls() functions to see the list of objects currently available

objects()
ls()
Objects in R Language

Remove Objects and Functions

Question 6: How do I remove/delete unwanted objects and functions?
Answer: The rm() function can be used to delete or remove the objects that are not required. The commands below will delete objects named object_name1 & object_name2 and functions named function_name1 & function_name2.

rm(object_name1, object_names2)
rm(function_name1, function_name2)

https://gmstat.com

https://itfeature.com