27 September 2016

How to get help in R ? R–Tips

R is very useful for data analysis but it surely need some programming skills. The one solid reason why analyst prefer r is its availability and flexibility with packages. The count of packages in CRAN is increasing day by day and it already consist of more than 4000 packages from Biometrics to Econometrics. Its really very hard to remember syntax and functions in packages. In this post I give you some important commands that could be very handy while working in R.

1. Using ?

If you want help on a function or a dataset that you know the name of, type ? followed by the name of the function. For example:
?mean opens the help page for the mean function
?"+"    opens the help page for addition
?"if"    opens the help page for if, used for branching code

2. Using ??

To find functions, type two question marks (??) followed by a keyword related to the problem to search. Special characters, reserved words, and multiword search terms need enclosing in double or single quotes. for example:
??plotting                    searches for topics containing words like "plotting"
??"regression model"    searches for topics containing phrases like this

3. help and help.search

The functions help and help.search do the same things as ? and ??, respectively, but with these you always need to enclose your arguments in quotes. The following commands are equivalent to the previous examples:help("mean")
help.search("regression model")

4. example and demo functions

Most functions have examples that you can run to get a better idea of how they work. Use the example function to run these. There are also some longer demonstrations of concepts that are accessible with the demo function:
demo()                    #list all demonstrations

5. vignettes

R is splits into package, some of which contain vignettes, which are short documents on how to use the packages. You can browse all the vignettes on your machine using browseVignettes :
You can also access a specific vignette using the vignette function (but if your memory is as bad as mine, using browseVignettes combined with a page search is easier than trying to remember the name of a vignette and which package it’s in):
vignette("Sweave", package = "utils")

6. RSiteSearch

The help search operator ?? and browseVignettes will only find things in packages
that you have installed on your machine. If you want to look in any package, you can use RSiteSearch, which runs a query at
http://search.r-project.org. Multiword terms need to be wrapped in braces:
leave your queries in comment section and Subscribe to I'm Sulthan by Email for more interesting updates. Share with your friends.  Thank you.