Yo yo yo.
R has very in-depth help files associated with pretty much everything it does. You can access the help files in many ways. First, you can google your question and end up at a website with a PDF of the packages you want help for (usually at cran.r-project.org) or just a general website with information. For example, if I google "R glmulti" (glmulti is a package in R - we will talk about packages in the next blog), you will see something like below. The second option here (the PDF) is the help file for the glmulti package. It gives you all the info you need for the package. Unfortunately R package help files are very convoluted.
Your next option is to type two question marks followed by the function you are interested in getting help for -- in either the console (then hitting enter), or in the R script viewer (see 2 posts ago for the differentiation between these). For example, I may be interested in finding the help file for the table function in R (table is a built in function that gives you the frequencies of a variable... like proc freq for SAS). In this case, I would type ??table in the R console or in the R script viewer as follows:
Once you hit command+enter (if you type it into the R script viewer as I have) or enter (if you type it into the console at the bottom), you will see some info on the bottom right window (see the Search Results R, with a bunch of crap over there? Yup, thats it).
Next, you need to scroll down in that window to actually find the function you want the help for. There are multiple sections here.. THe first section is Vignettes, the second is Code Demonstrations, and the third is Help files. You may have different numbers of options here depending on how many packages you have installed. For example, the first option in my Code Demonstrations (as you can see in the picture above) is graphics::Hershey. The way this is laid out is the package name followed by two colons, followed by the function name. So if you wanted help for the function Hershey, you could type ??Hershey in the console or R script viewer and this would be one of the options. The part before the two colons is the package in which the function resides. So if you dont have the graphics package installed, you wont see this option. Since the Hershey function has the function table in it also, it shows up here. Many functions also contain the table function, so you see a bunch of crap when you run the ??table. If you scroll down into the Help files section, you will see base::table. R, after you download it has a number of "packages" pre-installed. Two of the most commonly used are "base" (the base R application) and "stats". So if you see anything with base or stats before the two colons, these are just the basic functions built into R. If you scroll down, you will eventually see something like this (the last option here is base:: table -- click it and you will see the R help file for table).
I still find the R help files to be... well.. not that helpful. They are just too damn complicated. Over time, you kind of get used to the way things are written and can make your way through them.
I find the website www.statmethods.net (AKA Quick R) to be extremely helpful and very basic (sometimes too basic -- if that is possible). If you have a question, I would start with this website. The UCLA biostats site is also extremely helpful for R, SAS, SPSS, and STATA (http://www.ats.ucla.edu/stat/ ).
These two sites should be a good way to start with R. Next up - what is this package business, and why do I care?



No comments:
Post a Comment