Вы находитесь на странице: 1из 4

28 January 2017

ASSIGNMENT 2

There are four parts to this assignment


1. Load two datasets (using two methods)
2. Install a package from CRAN
3. Create a R Markdown document
4. Give some feedback

Please post any questions/issues on the Discussion Board

PART I

We are going to work with Datasets provided online by Vanderbilt University

http://biostat.mc.vanderbilt.edu/wiki/Main/DataSets

Navigate to this site and find the entries for

Diabetes data

Duchenne Muscular Dystrophy Dataset

Click on the first (html) entry for each to get the explanation of the dataset. The last link in the
row is another html entry that will give specific details on the data that you will be loading. You
do not need to download these html pages as you can just view them on the Vanderbilt sites.
You do need to download the following datasets. Put them in the working directory that you
are using for this assignment.

FIRST SET: diabetes.sav and diabetes.xls. [NOTE: two versions of same dataset]

SECOND SET: dmd.sav and dmd.csv. [AGAIN: two of same]

Lets take advantage of RStudio to load the dmd.csv first.

When I use this


tool, I am prompted
to add packages.
This pop up happens when I select
load CSV

Install the package

Browse to the file (in your working directory)


Then IMPORT. You should see it displayed in
upper left pane (dmd data.frame)

RStudio used the readr package HOWEVER we could have used a {base} installed package
read.csv. Type this command in your console window:
>dmd2 <- read.csv(dmd.csv")

When you View(dmd2), you should have a data.frame similar to dmd already loaded.

At the console > type:


rm(dmd)
NOTE: the dmd data.frame is no longer in the environment

Now we will - check out the help entry for attach


> attach(dmd.sav")

Then type
dmd3 <- dmd
Next View(dmd3) and compare with dmd2. (as you know you can either use RStudio upper
right pane to get view of loaded data.frame or use the function View() at the console.

NOTE: why dmd is addressable may seem like magic but all will become clear in class -
although you are welcome to sort it out on your own. [HINT: it actually is in your working
environment when you do the assignment command - just hidden)

[dont bother importing the diabetes.xls - just copy it to your working directory -we will
work with this later in class]
PART II

So far you have used functions that have either are included in loaded packages (I will explain
more about this in class) OR in packages that you are not loaded but are in your library. The
way you load the packages in your library are to use the library() function. You can check on
this by looking in the packages tap in RStudio.

1. Open the Packages tab


2. Note that the foreign package is not checked [loaded packages are checked].
3. In the console type library(foreign).
4. In the help tab - check out the entry for library.
5. Keep your eye on the packages tab and then type require(formatR) at the console
6. Again check out help for the require entry.

OK, so now what do you do if you need a package that is not in your library? Simple: you
install the package in your library (from CRAN). Here is how. - please actually install this
pack
1. At the console > type install.packages(Hmisc)
2. load(Hmisc)
3. In help look at Hmisc.overview
4. For the assignment submission take a screen shot of this help entry (just a partial shot of the
heading is fine).

PART III

In RStudio open a new R Markdown file. Remember you will get a template. You are going
to edit that template to have it do the following R code chunks.

1. CHUNK 1
attach(diabetes.sav)
Diabetes_data <- diabetes
2. CHUNK 2
scatter.smooth(Diabetes_data$ratio)

REMEMBER: to keep code chunks within the grey box

Try to clean-up what the template provides to have pertinent information to this task - and
include your name etc. You will need to use knitr to render the document into an HTML -
Take a screen shoot of the resultant HTML document to include in the assignment submission.

PART IV

We have gone through of a lot of R material. Please answer at least ONE of the following (you
can give more feedback if you would like)
1. What is the most puzzling aspect of R to you so far? [as said above, can do more than
ONE]
2. If all is clear (nothing to answer in #1), what use can you envision for R in your research?
PLEASE SUBMIT
PART I - were you able to complete as shown above? If there were any issues, please give
your work around.

PART II - provide screenshot requested

PART III - provide screenshot requested

PART IV - provide minimum (or more) feedback requested.

Вам также может понравиться