9

Is there an equivalent of dir function (python) in R?

When I load a library in R like -

library(vrtest)

I want to know all the functions that are in that library.

In Python, dir(vrtest) would be a list of all attributes of vrtest.

I guess in general, I am looking for the best way to get help on R while running it in ESS on linux. I see all these man pages for the packages I have installed, but I am not sure how I can access them.

Thanks

signalseeker
  • 4,100
  • 7
  • 30
  • 36

3 Answers3

8

Yes, use ls().

You can use search() to see what's in the search path:

> search() 
[1] ".GlobalEnv"        "package:stats"     "package:graphics"
[4] "package:grDevices" "package:utils"     "package:datasets"
[7] "package:methods"   "Autoloads"         "package:base"

You can search a particular package with the full name:

 > ls("package:graphics")
 [1] "abline"          "arrows"          "assocplot"       "axis"
 ....

I also suggest that you look at this related question on stackoverflow which includes some more creative approaching to browsing the environment. If you're using ESS, then you can use Ess-rdired.

To get the help pages on a particular topic, you can either use help(function.name) or ?function.name. You will also find the help.search() function useful if you don't know the exact function name or package. And lastly, have a look at the sos package.

Community
  • 1
  • 1
Shane
  • 98,550
  • 35
  • 224
  • 217
8

help(package = packagename) will list all non-internal functions in a package.

hadley
  • 102,019
  • 32
  • 183
  • 245
1
help(topic) #for documentation on a topic
?topic

summary(mydata) #an overview of data objects try

ls() # lists all objects in the local namespace

str(object) # structure of an object
ls.str() # structure of each object returned by ls()

apropos("mytopic") # string search of the documentation

All from the R reference card

pufferfish
  • 16,651
  • 15
  • 56
  • 65