Jie
Jie

Reputation: 418

What's the differences between help and ? and ?? in R language

I want to find the instruction of a function of a R package, so I run help('pkg::name'). But I got the message saying 'no document for that'. I retried ??pkg:name and it returned a very short instruction. When it came to ?pkg:name, the full instructions showed up. What are the differences between ? and ?? and help()?

Upvotes: 3

Views: 1080

Answers (2)

Samuel
Samuel

Reputation: 3053

The ? and ?? are short hands for help() and help.search() respectively.

For example:

help("lm")
help.search("linear models")

You use the first function when you know exactly what to search for, and the second function when you know approximately what to search for.

Upvotes: 2

Spacedman
Spacedman

Reputation: 94202

You can read the help for "?":

> ?"?"

and the help for "??":

> ?"??"

in short, "?" finds the help for a single existing item, and "??" searches the help for some text. So "??random" searches for "random", and "?random" tries to find something called "random" (which doesn't exist so I get a message).

Upvotes: 6

Related Questions