R for Researchers: R Scripts solutions

April 2015

This article contains solutions to exercises for an article in the series R for Researchers. For a list of topics covered by this series, see the Introduction. If you're new to R we highly recommend reading the articles in order.

There is often more than one approach to the exercises. Do not be concerned if your approach is different than the solution provided.

Exercise solutions

  1. Create a new script titled AlfAnalysis. This script will be used for the exercises in this article series.

    There is no code associated with the solution to this problem.

  2. Set up the session for the AlfAnalysis. Load the same packages as were used in SalAnalysis.

    #####################################################
    #####################################################
    ##
    ##   Analysis work on the Alfalfa data set 
    ##   
    ##   This script is a collection of the exercises
    ##   from the R For Researchers series.
    ##    
    ## 
    ##   Earnest Student        2/3/2015
    ##
    #####################################################
    #####################################################
    
    #####################################################
    #####################################################
    ##
    ##   Session Setup
    ##
    #####################################################
    #####################################################
    
    library(faraway)      # glm support
    library(MASS)         # negative binomial support
    library(car)          # regression functions
    library(lme4)         # random effects
    library(ggplot2)      # plotting commands
    library(reshape2)     # wide to tall reshaping
    library(xtable)       # nice table formatting
    library(knitr)        # kable table formatting
    library(grid)         # units function for ggplot
    saveDir <- getwd()  # get the current working directory
    saveDir             # show me the saved directory
    
    wd <- "u:/RFR"      # path to my project
    setwd(wd)           # set this path as my work directory
  3. Commit your changes to AlfAnalysis.

    There is no code associated with the solution to this problem.

Return to the R Scripts article.

Last Revised: 2/4/2015