views:

122

answers:

3

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

+5  A: 

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.

Shane
Thanks. I guess search() followed by ls("package:vrtest") is the way to do it.
signalseeker
You can also just provide the numeric position of the package in ls(). For the example of the graphics package, you could have done ls(3)
geoffjentry
A: 
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
Thanks! R reference card is a great resource.
signalseeker
+3  A: 

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

hadley