The R Clinic

The R Clinic was a weekly clinic to assist with learning R and troubleshooting difficult programming questions. It has since transformed into the Statistical Computing Series. Many useful links and handouts from the R Clinic are provided below.

Helpful R code:

I have a feeling that the answers to a lot of your questions can be found in Terri Scott's R lectures mentioned above, so please check there first. However, her lectures are not all-inclusive. The following are 'solutions' to questions posed to and topics discussed during the R Clinic. I use the term "solution" loosely; in R, there is never just one solution. These are just the solutions found in the clinic. Also, make sure you check out the 'Sweave and LaTeX' link in the 'Related Topics' section below for any Sweave and/or LaTeX related helpful tips.

Graphics

  1. An alternative to 'dynamite plots' (i.e., a bar depicting the mean, with a line depicting the standard deviation or error)
  2. Using the layout() function to generate multiple plots
  3. Drawing outside of the plotting region (e.g., lines or a legend)
  4. Adding a 'broken' axis to a plot
  5. A back-to-back barplot from scratch
  6. Distinguishing a second categorical variable by color in a stripchart across groups
  7. The generic datadensity() function
  8. Plotting linear model results
  9. Plot the Kaplan-Meier (K-M) curves from two different K-M calculations on the same plot
  10. A plot that illustrates the effect of categorizing continuous covariates in a logistic regression model
  11. Plot the odds ratios (ORs) for a specific covariate from different logistic regression models
  12. Incorporate the third contrast of a three-level categorical predictor into the odds ratio summary plot of a logistic regression model
  13. Dot charts using Hmisc dotchart2 and Dotplot
  14. Nonparametric smooth trend lines using Hmisc plsmo


Data Manipulation

  1. Converting dates of the form 'mddyy', 'mddyyyy', 'mmddyy', or 'mmddyyyy' to the form 'YYYY-MM-DD'
  2. Coding factors with numerical levels instead of character ones (i.e. No/Yes coded as 0/1)
  3. Generating a complex table of drug, disease, and phase
  4. Generating a variable that correctly labels each subject's records as their first, second, etc. visit according to a visit date
  5. Finding the sum of repeated continuous variables for each subject
  6. Rafe's problem
  7. Jonathan's problem
  8. Preparing data for survival analysis
  9. Cole Beck's baseball data set problem
  10. Rafe's data reshape problem


User-defined functions

Also check out the RCookBook Twiki site.
  1. How to write your own functions and good R programing techniques
  2. A function that displays the colors you can specify using the colors() function
  3. A function that returns the desired output from another function
  4. REFACTOR Cole Beck's proposed multiple sorting solution


Other

  1. Generating data structures in a memory efficient manner
  2. Writing a list of vectors to a file
  3. Viewing wide matrices and data frames with scrolling
  4. Using the Hmisc package's summary.formula() function
  5. Survival analysis with the survival and Design packages
  6. Block Randomization with Random Block Sizes
  7. Generating multiple regression models in a for loop
  8. Parsing email lists to create better output

Related Topics

  • Sweave and Latex
  • Writing R Extensions
  • R and VIM: Instructions on how to install custom vim syntax and indent files. These files enable vim to indent R correctly and syntax highlight common function names.
  • Emacs and ESS
  • Firefox extension for "R Site Search" (i.e., search for your R routines directly from Firefox -- see http://addictedtor.free.fr/rsitesearch).
    • Mango Solutions, providers of R and S-Plus consulting, application development and training, have announced the first release of the R Site Search extension for Mozilla Firefox. This extension enables you to search from Jonathan Baron's R Site Search (http://search.r-project.org) in a convenient way.
    • It will enable you to conveniently browse or search the content of the packages listed in Jon's server. Browsing is arranged in a 'package/documentation file' tree. Each hit is accompanied with a small icon which highlights the type of found object. This is useful as you can quickly find which page is refers to a dataset, clustering, time series etc...
    • Searching builds a new tree transparently on http://search.r-project.org and it shows only the relevant pages which may be viewed from the tree itself. Additionally the extension handles filters on the package names. Some examples are given on the homepage but I'm sure there are already regex-friendly people around with more ideas!

This topic: Main > WebHome > Seminars > RClinic
Topic revision: revision 97
 
This site is powered by FoswikiCopyright © 2013-2022 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Vanderbilt Biostatistics Wiki? Send feedback